How to printf long long?

When compiling with Mingw 32bit, the size of long and unsigned long is 4 bytes, the size of long long and unsigned long long is 8 bytes.

  • To print a long integer, the format of printf is “%ld”.
  • To print an unsigned long integer, the printf format is “%lu”.
  • To printf a long long integer, you should use “%lld” as the format of printf.
  • To display an unsigned long long integer, the print format string you should use is “%llu”.

If you use “%lu” to display an unsigned¬† long long integer, you may get “0” output, which is not you want.



Leave a Reply