S
sagenaut
I am puzzled for the following code:
ostringstream oss;
oss << "this is a test";
const char* test = oss.str().c_str();
the "test" get a empty c-string instead of "this is a test". But if I
do this:
string mystr = oss.str();
const char* test = mystr.c_str();
then the "test" get the "this is a test" c-string.
Why?
I run this code in VC++2025
Thanks in advance.
ostringstream oss;
oss << "this is a test";
const char* test = oss.str().c_str();
the "test" get a empty c-string instead of "this is a test". But if I
do this:
string mystr = oss.str();
const char* test = mystr.c_str();
then the "test" get the "this is a test" c-string.
Why?
I run this code in VC++2025
Thanks in advance.