Reputation: 41
int vari=10;
MessageBox(NULL, "<3 FAMOUS 10 <3 ","Lesson1", MB_OKCANCEL);
I want to display vari in below message box, so how I can?
Upvotes: 0
Views: 1523
Reputation: 211230
Use CString::Format
to create a message similar to printf
:
#include <afx.h>
int vari=10;
CString msg;
msg.Format( _T("value = %d"), vari );
MessageBox(NULL, msg, _T("Lesson1"), MB_OKCANCEL);
Upvotes: 3
Reputation: 3373
You can format your output string by printing values to it, than display it as dialog message:
char buffer[0xff];
int value = 10;
sprintf(buffer, "the value of variable is: %d\n", value);
MessageBoxA(NULL, buffer, "Lesson1", MB_OK);
Upvotes: 1