I want to convert decimal number 64 into hex representation: 0x00000040. I am using
printf("0x%X", 64);
but it gives output: 0x40. Can anyone please help me how to represent the decimal number in 0x00000000 format?
You can specify the length of the field between the % and the X (e.g. %8X). By default, the number will be padded with spaces, but using a leading zero for the length (e.g. %08X) will cause printf to pad with zeroes instead. Therefore, the following can be used:
printf("0x%08X", 64);
User contributions licensed under CC BY-SA 3.0