Last bits of memory addresses are same irrespective of machine
I was running this simple code and I noticed that the result of this code had the last two hex digits in the address same across all machines. #include <iostream> using namespace std; int main() { int x = 10; int *p = &x; cout << p << endl; cout << &p << endl; return 0; } I was getting c and 0 on my machine. I noticed my friend also got the same. Even running this on the online compilers got me the same c and 0 (and in the same order too). My question is why does this happen? I can understand that the difference between 0 and c would be of 4 bytes since that is the size of integer. That should
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.