Answer the question
In order to leave comments, you need to log in
C++. Why does adding +1 to an address increase the address by 8?
int *x = new int(42);
cout << &x << endl;
cout << (&x) + 1 << endl;
output:
0x7fffa5c115c8
0x7fffa5c115d0
Answer the question
In order to leave comments, you need to log in
Because the pointer starts pointing to the next element of the dimension for which the pointer was created. Make unsigned char* - it will increase by the size of char (1 most likely), unsigned long long* - by 8. void* most likely will not allow such a trick to turn at all (and will do it right).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question