Tech Support > Microsoft Windows > Development Resources > Variables | MessageBox (c++ | WINAPI)
Variables | MessageBox (c++ | WINAPI)
Posted by CAHEK on April 9th, 2008


Hi all!
I would display an integers or other variavbles(non char) in my messageboxes
anybody knows how to do this?

Posted by Alf P. Steinbach on April 9th, 2008


* CAHEK:
Convert to string.

In e.g. VBScript and JavaScript/JScript that's done automatically for you.

E.g., JavaScript (save this in file [blahblah.js] and double-click to run):

WScript.Echo( 'To plus to equals ' + (2 + 2) );

Above it's the JavaScript implicit conversion to string that's invoked.

Alternatively you can let e.g. WScript.Echo (or other host environment function)
do the conversion, in which case it's likely that it then adds
internationalization such as using Norwegian decimal comma on a Norwegian
Windows installation:

WScript.Echo( Math.PI );

The difference here being that the non-string is passed directly as argument.

Cheers, & hth.,

- Alf

Posted by Sebastian G. on April 9th, 2008


CAHEK wrote:



char[100] str;
int * intptr;
sprintf(str, "%i,%p,%d",1,intptr, 3.14);

Now if you don't even know sprintf(), which is likely due to your question,
you should stop your program now and first read up the basics.


Similar Posts