int x = 99;
printf("&x = %p\n", &x);
printf("&x = %d\n", &x);
std::cout << &x << std::endl;
std::cout << std::dec << &x << std::endl; // problematic line (5)
std::cout << std::dec << 0x0D << std::endl;
The output is:
&x = 0x7ffe5f1d0434
&x = 1595737140 // I don't think this is correct.
0x7ffe5f1d0434
0x7ffe5f1d0434
13 // decimal of 0x0D
I don't understand why fifth line above does not output decimal representation of the address of variable x
. My usage of std::dec
should be correct, because it works for 0x0D
. So, I suspect &x
might not be a hexadecimal number as I think it is. But, I am not sure, so wanted to ask.
Thanks in advance.