一维数组寻址
数组名表示[数组第0个元素]的[地址][常量]
type array[M]
array[N] address is
(int)array + sizeof(type) * N
数组长度
sizeof(array) / sizeof(array[0])
二维数组寻址
type array[N][M]
type array[x][y] address is:
(int)array + sizeof(type[M]) * x +sizeof(type) * y
指针寻址
array是表示数组第0个元素地址的指针常量,指针类型为元素类型
type array[M];
array[n] <==> *(type *)((int)array +sizeof(type)*n);
type *ptr = xxxx;
type *ptrTest = xxxx;
int n = xxxx;
(ptr + n) is (int)ptr + sizeof(type)*n;
ptr + n <==> (type * const)((int)ptr +sizeof(type)*n);
ptr - ptrTest <==> ((int)ptr - (int)ptrTest) /sizeof(type);
array[n] == *(array + n);
&array[n] == array + n;
type *ptr = array;
type[n] == array[n];
ptr++; //OK
array++; //ERROR, array is pointer const