-
How would I do something like this:
PHP Code:
int score;
char bufferScore[4];
itoa(score, bufferScore, 10);
MessageBox...
I want it to say "Your score is (whatever it is), good job!" or something like that...in vb its the &, what is it in C++ :confused:
-
Code:
#include <iostream.h>
#include <windows.h>
int main(int argc, char* argv[])
{
int score = 5555;
char bufferScore[5];
itoa(score, bufferScore, 10);
char allText[] = "Your score is ";
strcat(allText,bufferScore);
strcat(allText," good job");
MessageBox(NULL,allText,"ok",MB_OK);
return 0;
}
or use the string class (much easier)
Code:
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
string t1 = "text1";
string t2 = "text2";
string all = t1+t2;
MessageBox(NULL,all.c_str(),"Caption",MB_OK);
return 0;
}
-
Just what I wanted...Thanks Vlatko! :D :) ;) :cool: :cool: :cool:
(Damn you John/James, now I'm gonna go smilie happy! :mad: )
-
Or how about my printf-style MsgBox function?
Code:
int MsgBox(HWND hParent, int iFlags, TCHAR *pcCaption, TCHAR *pcText, ...) {
va_list args;
TCHAR pcBuf[1024];
va_start(args, pcText);
_vsntprintf(pcBuf, 1024, pcText, args);
va_end(args);
return MessageBox(hParent, pcBuf, pcCaption, iFlags);
}
-
That format string code is really nifty. I like :) I've seen it before, here and other places too, but it's still kinda cool ;)
Geeky huh? :)