Why can one printf() in C not print two 64-bit values at the same time?

后端 未结 5 1405
走了就别回头了
走了就别回头了 2020-12-29 00:14

I am working on a 32-bit system. When I try to print more than one 64 bit value in a single printf, then it cannot print any further (i.e. 2nd, 3rd, ...) variable values.

5条回答
  •  南方客
    南方客 (楼主)
    2020-12-29 00:42

    It prints them all on my computer, but there are three compile time warnings since %llx expects a long long unsigned int.

    Are you sure you need to be using 64 bit types though? All three of your hexcodes are only 32 bits. Maybe you could just use 32 bits and do:

    unsigned int a = 0x12345678;
    unsigned int b = 0x87654321;
    unsigned int c = 0x11111111;
    
    printf("a is %x & b is %x & c is %x",a,b,c);
    

    (Or use the stdint equivalent of 32bit unsigned int)

    Unless you need them to be 64 bits so you can add more bits to them later.

提交回复
热议问题