I have a wstringstream:
wstringstream sstream;
AlterSstream(sstream);
wstringstream bar_stream;
bar_stream << sstream;
bar_stream << "foo";
MessageBoxW(
NULL,
bar_stream.str().c_str(),
L"subject",
MB_OK
);
This outputs a long string that looks nothing like what I put in it in AlterSstream()
:
00000000002CEC58foo
AlterSstream:
void AlterSstream(wstringstream& outStream)
{
outStream << "odp";
}
Why is this happening? If I print out sstream
directly, it works fine, but printing out bar_stream
creates the problem. I'm guessing that the <<
operator doesn't work the way I think it does between two streams?
UPDATE: Sorry, I had left a bit of code out originally. It is fixed above.