Array references in two different ways [duplicate]
Possible Duplicate:
In C arrays why is this true? a[5] == 5[a]
int a[5]={1,2,3,4,5};
int i=4;
printf("%d",i[a]);
Why do a[i] and i[a] refer to same location in the array?
This is because array subscript is commutative (it's an addition), the order can be swapped :
a[i] = *(a + i)
i[a] = *(i + a)
*(a + i) = *(i + a)
a[i] = i[a]
精彩评论