Tag Archives: arrays

Arrays 5[a] == a[5]

First time I saw that I thought it was weird.
Thinking more about it, it actually makes a lot of sense.

Consider the a array, with the 6 elements
The memory address of this array is a.

The first element of the array evaluates to *(a).
So, the 6th element can be written as *(a + 5).
And as *(5 + a), thus 5[a].