printf uint64_t

This is a discussion on printf uint64_t within the C Programming forums, part of the General Programming Boards category; Hi guys. Can anyone explain me how i can printf variables of the type uint64_t ? Thank you....

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    5

    printf uint64_t

    Hi guys. Can anyone explain me how i can printf variables of the type uint64_t ?

    Thank you.

  2. #2
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,058
    Code:
    uint64_t var;
    printf("var = %llu\n", var);

  3. #3
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,701
    With the MS-CRT on windows, you use the "I64" prefix. For everything else you use C99 prefix "ll". Since your type is unsigned, then the full format would be either "%I64u" or "%llu".

    gg

  4. #4
    Registered User
    Join Date
    Apr 2008
    Posts
    5
    Thank you guys. Problem solved

  5. #5
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Actually it's PRIu64.
    Code:
    #include <inttypes.h>
    #include <stdio.h>
    
    int main() 
    {
            uint64_t i = 5;
    
            printf ( "&#37;" PRIu64 "\n", i ) ;
    
            return 0;
    }

  6. #6
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    &#37;llu is more portable from my experience.

  7. #7
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Which platforms did not support the PRI defines?

  8. #8
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    I probably should have put "To Codeplug" somewhere in my post. The PRI defines are not the most asthetically pleasing way of doing things.

  9. #9
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    True, but they can work on whatever platform, unlike hardcoding it.

  10. #10
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Fair enough. This is one area where I will have to give the win to iostreams. These days printing a 64-bit value is not as unlikely an event as it once was.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. making it portable.....?
    By ShadeS_07 in forum C Programming
    Replies: 11
    Last Post: 12-24-2008, 09:38 AM
  2. get keyboard and mouse events
    By ratte in forum Linux Programming
    Replies: 10
    Last Post: 11-17-2007, 05:42 PM
  3. segmentation fault upon reload
    By yabud in forum C Programming
    Replies: 8
    Last Post: 12-18-2006, 06:54 AM
  4. Simple C question: user input to repeat a loop
    By evernaut in forum C Programming
    Replies: 2
    Last Post: 11-18-2006, 09:23 AM
  5. Drawing tables in C
    By stanoman in forum C Programming
    Replies: 5
    Last Post: 10-09-2003, 11:14 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21