I'm trying to use std::ostringstream to convert a number into a string (char *), but it doesn't seem to be working. Here's the code I have:
#include <windows.h>
#include <sstream>
int main()
{
std::ostringstream out;
out << 1234;
const char *intString = out.str().c_str();
MessageBox(NULL, intString, intString, MB_OK|MB_ICONEXCLAMATION);
return 0;
}
The resulting message box simply has no text in it.
This leads me to believe that the call to out.str().c_str()
is returning an invalid string, but I'm not sure. Since I've trimmed this program down so far an am still getting the problem, I must have made an embarrassingly simple mistake. Help is appreciated!