Click to See Complete Forum and Search --> : type specifier for 64-bit integers ?


susiriss
February 7th, 2005, 02:39 AM
Dear friends,
I wanted to write a 64-bit integer to a string and used the wsprintf function as below. Although the value is correctly assigned to the variable, it seems like truncated in the printed string.

ULONGLONG DiskSize;
:
:

wsprintf(msg," Disk size = %lu bytes", DiskSize);

Is there any special type specifier that can be used with wsprintf() instead of %lu? (%I64d doesn't work with wsprintf() )

Help me ...!

susiriss.

NoHero
February 7th, 2005, 03:21 AM
I thought this function named swprintf (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/html/_crt_sprintf.2c_.swprintf.asp)? And this function worked fine for me. BTW it is:


wsprintf(msg, L" Disk size = %lu bytes", DiskSize);


Otherwise this string literal is not unicode.

OReubens
February 7th, 2005, 01:59 PM
the Windows API function wsprintf() does not support 64 bit integers, nor does it support floating point variables of any kind.

The easiest solution would be to use the sprintf() function available in the C Runtime libary.
If your are aiming for a small footprint, that will require the CRT, and will add quite a bit of code (mainly because of the FPU support the CRT sprintf() has.

Alternatively, you could use %s for int64, and create a function that converts an int64 to a string yourself before passing it to wsprintf().