Closed ghost closed 4 years ago
I think that str1 is a dangling pointer. I have only one question: why the same code works fine with std::string (...).c_str()?
duplicate #26, #27
I think that str1 is a dangling pointer.
Yep. str2 is a dangling pointer too btw.
I have only one question: why the same code works fine with std::string (...).c_str()?
🤷 just lucky I guess, because it shouldn't and most likely if you just add some more stuff it will instantly break.