Deallocating after c_str()?

Do I have to worry about deallocating the memory used by a string gotten by calling the c_str method from the string class?

for example,

1- string str("hey");
2- const char* cstr = str.c_str();
3- cstr = "abcd";

... after line #3 has been executed, what happened to the memory it was pointing to before?
You might want to try compiling that...
I just did.... it compiles
c_str() just returns pointer to the string's internal buffer so no need to clean up. Just be careful if you manipulate the string, pointers received from earlier calls to c_str() could be invalidated.
Gotcha!, Thanks Peter!
Topic archived. No new replies allowed.