Trouble with wstringstream

Posted by Rosarch on Stack Overflow See other posts from Stack Overflow or by Rosarch
Published on 2010-06-09T22:34:55Z Indexed on 2010/06/09 22:52 UTC
Read the original article Hit count: 132

Filed under:
|

I have a wstringstream:

wstringstream sstream;
AlterSstream(sstream);

sstream << "foo";

MessageBoxW(
  NULL,
  sstream.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?

© Stack Overflow or respective owner

Related posts about c++

Related posts about string