Posts

Showing posts with the label 64bit

print 64bit c++ full memory address

print 64bit c++ full memory address While I was writing code on a 64 bit machine for a c++ program,I noticed that printing the address of a variable (for example) returns just 12 hexadecimal characters, instead of 16. Here's an example code: int a = 3 ; cout sizeof(&a) << " bytes" << endl ; cout << &a << endl ; The output is: 8 bytes 0x7fff007bcce0 Obviously, the address of a variable is 8 byte (64 bit system). But when I print it, I get only 12 hexadecimal digits instead of 16. Why this? I think that is due to the fact that the 4 "lost" digits were leading zeroes, that were not printed. But this is only my thought, and I wish to have a definitive and technically correct answer. How could I print the entire address? Is there a built-in solution, or should I manually use "sizeof" in order to get the real lenght and then add to the address the right number of zeroes? Forgive me, I googled for a day for an answer to my stup...