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(“%#010xn”, i); // gives 0x00000007
printf(“0x%08xn”, i); // gives 0x00000007
printf(“%#08xn”, 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
The “0x” counts towards the eight character count. You need “%#010x”.
Note that # does not append the 0x to 0 – the result will be 0000000000 – so you probably actually should just use “0x%08x” anyway.