std::string has a member c_str() which returns a C-style array.
To "convert" a C array char * to a C++ std::string simply use the latter's constructor, or assignment operator. Example:
1 2 3 4 5 6 7
char something[100];
std::string something_else = "A thing.";
std::strcpy(something, something_else.c_str());
std::string anewstring(something); // same as
anewstring = something;
hmm... really? (guess i've read it somewhere that string is const char*, but nevermind, don't really remember :)) ) then, why string is not defined as char*?
umm i cant understand your mean !!! but i have one question : if is const char , how can change it ?
for exm :
if string is const char then this is not be true !!!
string str;
str = "hello"; // why can i change it ?!!
string is typedef of basic_string<char, char_traits<char>, allocator<char> >
ok man i found for you some reference if you dont have trust to me !!!
in C++ CookBook "herbert schildt" is wrote :
"The first type of string supported by C++ is the null-terminated string. This is a char array
that contains the characters that comprise a string, followed by a null. The null-terminated
string is inherited from C and it gives you low-level control over string operations."
as you see , char array no const char array