I'm working with files containing large numbers (disk offsets) and have run into a problem using scanf for %lli - the numbers are of the format 0x... but scanf doesn't read all the bits.
Here's example code (I tested on https://www.onlinegdb.com/online_c_compiler).
#include <stdio.h>
#include <stdlib.h>
int main()
{
char* str = malloc(30);
unsigned long long l;
sprintf(str, "0x%llx\n", 0xffffffffffffffffULL);
printf("%s\n", str);
sscanf(str, "%lli", &l);
printf("%llx\n", l);
return 0;
}
It outputs:
0xffffffffffffffff
7fffffffffffffff
whereas I expect both numbers to be equal.
If I use the %llx specifier, it works properly, but I don't want to limit myself to hex-formatted numbers.