Basically I am trying to convert hex strings into unsigned long long values
using strtoull
. Here's the simple code
#include <stdio.h>
#include <string.h>
int main ()
{
unsigned long long val =0;
//printf("sizeof(unsigned long long)=%d\n", sizeof(unsigned long long));
val = strtoull("0x8004298c42ULL",NULL,16);
printf("%llx\n", val);
if ( val == 0x8004298c42ULL)
{
printf("Success\n");
}
return 0;
}
I expect val
to print 8004298c42
but it prints 4298c42
. The 8
is being chopped off. I tried without the 0x
and without the ULL
too. But still the same result. Just to make sure that I am not missing out on some trivial printf
format specifier thing, I even checked the contents of val
. Still no use( ie Success was not printed )
I think I am missing out something trivial but don't know what!