On 02/15/2011 07:13 PM, Paavo Helde wrote:
> Robert Hairgrove<> wrote in news:14522$4d5ab628
> $d9a2e747$:
>
>> On 02/15/2011 11:44 AM, Saurabh Gupta wrote:
>>> ostrstream m_msgStream;
>
> ostrstream has been deprecated for a long time already, I would suggest
> to switch over to ostringstream.
>
Oops ... overlooked that one!
>> Aside from that, you should realize that std::stringstream::str()
>> returns std::string, not char*. You should be using:
>
> He is using ostrstream, where indeed str() returns char*.
Oops again.
>> const char *str = m_msgStream.str().c_str();
>
> With ostringstream this would create a dangling pointer into a destroyed
> temporary std::string object!
And yet another oops!
|