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.

reference:https://stackoverflow.com/questions/38561/what-is-the-argument-for-printf-that-formats-a-long

https://stackoverflow.com/questions/2844/how-do-you-format-an-unsigned-long-long-int-using-printf

 

Leave a Reply