std::string::c_str() overwrittes the previous one returned by a function
问题 I could not understand that how can be the pointers same when the text size is equal. It seems like firstStringObj::c_str() overwrittes the previous one's pointer. #include <iostream> #include <string> #include <string> #include <stdio.h> std::string getConstCharAndModifyItWithANewString( const char* constchar ) { std::string stringAtStack( constchar ); stringAtStack += "::isModified"; return stringAtStack; } int main() { const char* firstConstCharPointer =