M
matish
Hi,
in:
string s("Hi");
const char* c = s.c_str();
how long will the pointed cstring live?
I see that calling delete c or delete []c fail, that the cstring survives
the end of the scope in witch it is decleard and even delete s does not
destroy it (I thougth c could be a pointer to some internal buffer of s,
but it seems not to be the case).
So, what should one do after having created a char* with c_str()? Delete it
in some way or leave it there?
Thanks
in:
string s("Hi");
const char* c = s.c_str();
how long will the pointed cstring live?
I see that calling delete c or delete []c fail, that the cstring survives
the end of the scope in witch it is decleard and even delete s does not
destroy it (I thougth c could be a pointer to some internal buffer of s,
but it seems not to be the case).
So, what should one do after having created a char* with c_str()? Delete it
in some way or leave it there?
Thanks