Show a small but complete example of code that produces that error.
Also be sure that you have the right #include statement:
#include <string>
- Wayne
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello,
I've written simple piece of code which compiles and works perfectly on any other program which can compile and run C++,
but when I try to run it from VS 2015 on my laptop or on VS 2017 from my other laptop, it won't build it - I get an error saying it doesn't recognize std e.g. it says "string is not a member of std"
I've checked and I think that I've installed all necessary extensions for C++ to work.
How can I fix it?
Thank you.
This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.
1 deleted commentComments have been turned off. Learn more
Show a small but complete example of code that produces that error.
Also be sure that you have the right #include statement:
#include <string>
the code:
std::ostringstream ss;
int i = 7;
ss << std::hex << std::showbase << i;
std::string str = ss.str();
const char *output = str.c_str();
the headers I've included:
#include <stdlib>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <strstream>
I also get an error "cannot open source file "stdlib""
As far as I'm concerned, you should use "#include<stdlib.h>" instead of "#include<stdlib>".
And I agree with RLWA32, you could try to use "#include <cstdlib>". It includes the C Standard library header <stdlib.h> and adds the associated names to the std namespace. For more details I suggest you could refer to the Doc:<cstdlib>.