Because std::string::c_str() doesn't transfer ownership with the pointer. The pointer belongs to the object that returned it and it's its responsibility to free it.
err so if let's say the string object goes out of scope/destroyed then my pointer that I used to point to the c style string after calling c_str() would become a dangling pointer?
ok thanks for the explanation, then if I explicitly called delete on my pointer which points to the c style string, then the string object would be left in an inconsistent state? or is there a mechanism to prevent this from happening?