ostringstream doesn't work with int

If you run this code compiled with gcc 4.2 (Xcode 3.2) you get an empty string. ostringstream doesn't convert int values to string!

Please, test this code with gcc compiler.

#include <iostream>
#include <sstream>

int main()
{
std::ostringstream stream;
stream << 45;
std::string str = stream.str();
std::cout << str; // empty output
return 0;
}

MacBook Pro 15" 2.4Ghz 2GB 500GB, Mac OS X (10.6.1)

Posted on Oct 28, 2009 8:24 PM

Reply
6 replies

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

ostringstream doesn't work with int

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.