CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2003
    Location
    Sri Lanka
    Posts
    120

    type specifier for 64-bit integers ?

    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.

    Code:
    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.

  2. #2
    Join Date
    Mar 2004
    Location
    (Upper-) Austria
    Posts
    2,899

    Re: type specifier for 64-bit integers ?

    I thought this function named swprintf? And this function worked fine for me. BTW it is:

    Code:
    wsprintf(msg, L" Disk size = %lu bytes", DiskSize);
    Otherwise this string literal is not unicode.
    I am not offering technical guidiance via email or IM
    Come on share your photo with us! CG members photo album!
    Use the Code Tags!

  3. #3
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: type specifier for 64-bit integers ?

    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().

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured