32/64-bit platform printf UInt64 method

Source: Internet
Author: User
In the 32-bit platform typedef unsigned long int uint64_t;
In the 64-bit platform typedef unsigned long int uint64_t;
Different typdef require that different length modifier,uint64_t be used in printf to use LL in 32 bits and use L in 64 bits. In addition to defining the data type, C99 also defines how the corresponding data type is printed, using PRIu64 to print UInt64, for example:

#include <stdio.h>
#include <inttypes.h>


int main (int argc, char *argv[])
{
    uint64_t u64 = ;
    printf ("UInt64:%" PRIu64 "\ n", u64);
    printf ("UInt64:%lu\n", u64);   x86_84
    //printf ("UInt64:%llu\n", u64);  x86 return
    0;
}

In addition to PRIu64, INTTYPES.H also defines macros for other data types. In addition, if it is a C + + program, you need to define __stdc_format_macros macros.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.