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
From C to shining C++!
Great graphics, sounds, algorithms, AI, pathfinding, visual effects, cutscenes, etc., etc. do NOT make a good game.
- Bubba
IDE and Compiler - Code::Blocks with MinGW
Operating System - Windows XP Professional x64 Edition
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.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);
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.