The #
part gives you a 0x
in the output string. The 0
and the x
count against your "8" characters listed in the 08
part. You need to ask for 10 characters if you want it to be the same.
int i = 7;
printf("%#010x
", i); // gives 0x00000007
printf("0x%08x
", i); // gives 0x00000007
printf("%#08x
", i); // gives 0x000007
Also changing the case of x
, affects the casing of the outputted characters.
printf("%04x", 4779); // gives 12ab
printf("%04X", 4779); // gives 12AB
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…