How can I store and/or print() a number that is larger than 4 294 967 295 in C? is int64_t or u_int64_t what I need ? if, so how can I printf it to stdout?
On HP-UX, this program works:
#include<stdlib.h>
#include<stdio.h>
main()
{
long i;
i=5000000000;
printf("i = %ld \n", i);
exit (0);
}
To get this to work I had to specify the +DD64 option on the cc command. HP's compiler defaults to 32 bit mode.
This page says:
I wasn't sure is this was HP-UX specific, there is a weirdicious feature in GCC that will make the aforementioned program work with two changes (at least under Linux)
Use data type
long long l; /* Not typo! will compile */
and printf("%Ld", l); /* Notice capital L */
If GCC is used on various Os'es, it should work.
(I just checked on Solaris, it prints 1
Atle