I have some trouble with a book that I am currently reading about C and assembly. The author uses a 32 bit environment while I am using 64-bit. The problem is that the author often uses
printf("%08x", &var);
To print addresses which works fine on 32 bit. But when I run this on 64-bit I get only half of the address while %p
gives me the whole address... So why is this so? I of course use %016x
instead of %08x
.
The author only uses %p
for pointers.
So when should I use what?
To print pointers in printf
, using %p
with void *
type is the way according to the C standard.
printf("%p", (void *)&var);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With