Format specifier for 'long long'

前端 未结 7 733
野性不改
野性不改 2021-02-02 07:05

I declare a variable for a 64 bit counter as :

long long call_count;

What is the format specifier that I should use in print statements?

<
相关标签:
7条回答
  • 2021-02-02 07:21

    Microsoft and Watcom use %I64d (capital eye), others use %lld (lowercase ell ell).

    0 讨论(0)
  • 2021-02-02 07:22

    This one and even little more has been described here: cross-platform printing of 64-bit integers with printf

    TL;DR: You can use PRId64 macro (from inttypes.h) to print 64 bit integers in decimal in a semi-portable way. There are also other macros (like PRIx64).

    0 讨论(0)
  • 2021-02-02 07:23
    long long t1;             //signed
    unsigned long long t2;    //unsigned
    
    printf("%lld",t1);
    printf("%llu",t2);
    
    0 讨论(0)
  • 2021-02-02 07:24

    It's "%lli" (or equivalently "%lld")

    0 讨论(0)
  • 2021-02-02 07:24

    Maybe %lld? I think this is the format for gcc, don't know anything about Diab C compiler.

    0 讨论(0)
  • 2021-02-02 07:37

    It is %lld for signed and %llu for unsigned

    0 讨论(0)
提交回复
热议问题