How do you format an unsigned long long int using printf?

Question :

How do you format an unsigned long long int using printf?,

Answer :

#include   int main() {      unsigned long long int num = 285212672; //FYI: fits in 29 bits      int normalInt = 5;      printf("My number is %d bytes wide and its value is %ul. A normal number is %d.n", sizeof(num), num, normalInt);      return 0;  }  

Output:

My number is 8 bytes wide and its value is 285212672l. A normal number is 0.  

I assume this unexpected result is from printing the unsigned long long int. How do you printf() an unsigned long long int?

,

Use the ll (el-el) long-long modifier with the u (unsigned) conversion. (Works in windows, GNU).

printf("%llu", 285212672);  

That’s the answer How do you format an unsigned long long int using printf?, Hope this helps those looking for an answer. Then we suggest to do a search for the next question and find the answer only on our site.

Disclaimer :

The answers provided above are only to be used to guide the learning process. The questions above are open-ended questions, meaning that many answers are not fixed as above. I hope this article can be useful, Thank you

Read More  Instrumenting Database Access