How do you printf an unsigned long long int?

Posted by superjoe30 on Stack Overflow See other posts from Stack Overflow or by superjoe30
Published on 2008-08-05T20:59:29Z Indexed on 2010/05/08 17:38 UTC
Read the original article Hit count: 333

Filed under:
|
#include <stdio.h>

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?

© Stack Overflow or respective owner

Related posts about c

    Related posts about syntax