42

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?

I tried, %l, %ld, %ll. None seems to be correct.

I use Diab C compiler for compiling my application code to run on pSOS operating system.

Ophir Carmi
  • 2,701
  • 1
  • 23
  • 42
Prabhu. S
  • 1,743
  • 2
  • 21
  • 34

7 Answers7

68

According to C99, it should be "%lld" (see, for example,here). If Diab C isn't C99, then you'd have to look at the compiler docs, which I can't seem to find online with a quick Googling.

Bdoserror
  • 1,184
  • 9
  • 22
17

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

Christoph
  • 164,997
  • 36
  • 182
  • 240
12

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

dreamlax
  • 93,976
  • 29
  • 161
  • 209
Graeme Perrow
  • 56,086
  • 21
  • 82
  • 121
6

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

Community
  • 1
  • 1
Caladan
  • 1,471
  • 11
  • 13
3

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

raupach
  • 3,092
  • 22
  • 30
  • 3
    %lld is the Standard conversion specifier for long long, Windows is the only one I am aware of that doesn't support this (but they don't support a lot of standards). Also, this is specific to the standard c library being used, not the compiler. – Robert Gamble Jan 20 '09 at 18:17
2

It is %lld for signed and %llu for unsigned

Gerhard
  • 6,850
  • 8
  • 51
  • 81
1
long long t1;             //signed
unsigned long long t2;    //unsigned

printf("%lld",t1);
printf("%llu",t2);
Aashish Kumar
  • 2,771
  • 3
  • 28
  • 43