|
-
Apr 3rd, 2001, 09:18 PM
#1
Thread Starter
Frenzied Member
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++
-
Apr 4th, 2001, 04:56 AM
#2
Frenzied Member
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;
}
-
Apr 4th, 2001, 06:03 AM
#3
Thread Starter
Frenzied Member
-
Apr 4th, 2001, 07:26 AM
#4
Monday Morning Lunatic
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);
}
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Apr 4th, 2001, 09:48 AM
#5
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|