I believe I understand how normal variables and pointers are represented in memory if you are using C.
For example, it\'s easy to understand that a pointer Ptr will
Your diagram is correct. The weirdness around &x
has nothing to do with how arrays are represented in memory. It has to do with array->pointer decay. x
by itself in value context decays into a pointer to its first element; i.e., it is equivalent to &x[0]
. &x
is a pointer to an array, and the fact that the two are numerically equal is just saying that the address of an array is numerically equal to the address of its first element.
int x[] produces the same result as int* x;
it's just a pointer
therefore notations x[i] and *(x + i) produce the same result.