char array to std::string

Started by
2 comments, last by technomancer 16 years, 2 months ago
yo How do I convert a character array to a std::string? thanx m0ng00se
Advertisement
Using std::string::operator = (const char*) method:

const char* c_string;std::string cpp_string;...c_string = "This is array of chars";cpp_string = c_string;


Thanx,

That worked perfectly.

m0ng00se
BTW: you can also construct a std::string from a const char * too

const char* c_string;
std::string cpp_string( c_string );

This topic is closed to new replies.

Advertisement