Address in Hex without a 0x?

I made a program to find the address of some simple variables, and it says that the address for them are 003AF79C for one and 003AF78C for the other. I know that this is in Hex (or at least I assumed so), but why does it start with 00 instead of the usual 0x?
Last edited on
Hex is short for HEXADECIMAL which is 16 symbols representing numerical values 0 - 15. They are the following 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E and F. 'X' is not one of those symbols so storing it as a value any where in the variable would be detrimental.

What you are used to seeing with the 0x prefix is more to inform the reader that they are looking at hex then to serve any real function to the program.
Last edited on
I knew that X wasn't used in counting C++, I just thought that a hexadecimal number always had the prefix 0x. Do hex numbers not always require the 0x if they are coming from the computer?
If you are outputting that with streams, the default is without 0x prefix.
See http://www.cplusplus.com/reference/iostream/manipulators/showbase/
Note that the examples above are padded with leading zeros because it's a 32 bit number.
if you're using printf you can say:
printf("%0#32x",0xff);
which gives:
0x000000ff

use %0#32X for capitals.
Last edited on
Topic archived. No new replies allowed.