Tried following code to check what happens when we convert integer pointer to a integer .
#include
#include
int main()
{
Here you're printing out the memory address of a
, but you're printing it as a signed decimal integer. It doesn't make too much sense as a format, because some high memory addresses, the exact boundary depending on your word size and compiler, will be printed as negative.
The standard is to print it as an unsigned hexadecimal padded with zeroes to 8 or 16 characters (really, this is dependent on the exact word-size again). In printf
, this would be %#08X
, so the memory address 0x243 would be printed as 0x00000243.