For example, have the message box say, "x equals 5, and that's just dandy".
For example, have the message box say, "x equals 5, and that's just dandy".
Code:#include <string>
[...]
std::string MessageText = "X equals ";
MessageText += X;
MessageText += ", and that's just dandy";
MessageBox(hWnd, "Title", MessageText.c_str(), MB_OK);
I posted about this awhile ago... Oh well, here is the first code that I got a hold of:
I use this way because it's the first way I got (and it works fine).Code:#include <sstream>
#include <windows.h>
int main( void )
{
int X = 5; // If this is what you mean't
std::stringstream Message;
Message << "X equals " << X << ", and that's just dandy.";
MessageBox( NULL, Message.str().c_str(), "Title", MB_OK );
return 0;
}
- SirCrono6
Are you sure? I thought you could only add strings and characters to a string. Any other types have to be added through a stringstream.Quote:
Originally posted by stovellp
Code:#include <string>
[...]
std::string MessageText = "X equals ";
MessageText += X;
MessageText += ", and that's just dandy";
MessageBox(hWnd, "Title", MessageText.c_str(), MB_OK);