问题
I have a issue trying to use scanf to get a big hexadecimal num (12 chars) from the user.
it seems to only get the last 8 chars, eg - ABFFFFFFFF will become 0000FFFFFFFF.
this is my code -
unsigned long long address;
scanf("%x",&address);
printf("Address: %#014x", address);
for this input: "ABFFFFFFFF" the output would be:
Address: 0x0000ffffffff
i have tried playing a bit with the scanf format, but to no avail.
回答1:
You must use "%llx" for both scanf format and printf. See the manual page for additional details.
来源:https://stackoverflow.com/questions/30561882/scanf-a-big-hexadecimal-value