I know this sounds like a n00bish question, but I can't figure out how to print a variable in an alert box. Can anyone here tell me how?
I know this sounds like a n00bish question, but I can't figure out how to print a variable in an alert box. Can anyone here tell me how?
Not a problem. A MessageBox takes a char* so you need to convert the integer into a string. Fortunately for us there is already a function for just that.
You'll need to include <stdio.h> if you haven't already.Code:char buffer[256] = { 0 }; int iNum = 55; // Format buffer for output sprintf( buffer, "Value is %i", iNum ); MessageBox( NULL, buffer, "Alert", NULL );
another way is u could use a string stream
(sorry 4 the dogey variable namesCode:#include <strstream> #include <string> using std::strstream; using std::ends; using std::string; stringstream Temp; LPCSTR eTemp; char Vara[]="The Magic Value IS: "; int Varb=21; char Varc[]=" OK? "; temp<<Vara<<Varb<<Varc<<ends; eTemp = temp.str();
then just pass eTemp to watever sub/function u want and it will contain the string int whatever
hope it helps