Can anyone please tell me how to convert a C style string (i.e a char* ) to a c++ style string (i.e. std::string) in a C++ program?
Thanks a lot.
std::string
can take a char *
as a constructor parameter, and via a number of operators.
char * mystr = "asdf";
std::string mycppstr(mystr);
or for the language lawyers
const char * mystr = "asdf";
std::string mycppstr(mystr);