C语言指针理解
#include <stdio.h> int main(void){ int zippo[4][2] = {{2,4},{6,8},{1,3},{5,7}}; printf(" zippo = %p, zippo + 1 = %p ",zippo,zippo +1); printf(" zippo[0] = %p, zippo[0] + 1 = %p ",zippo[0],zippo[0] +1); printf(" *zippo = %p, *zippo + 1 = %p ",*zippo,*zippo +1); printf(" zippo[0][0] = %d ",zippo[0][0]); printf(" **zippo = %d ",**zippo); printf(" *zippo[0] = %d ",*zippo[0]); printf(" zippo[2][1] = %d ",zippo[2][1]); printf(" *(*(zippo + 2) + 1) = %d ",*(*(zippo + 2) + 1)); printf(" zippo = %p,&zippo = %p,&zippo[0] = %p,zippo[0] = %p,&zippo[0][0] = %p,zippo[0][0] = %d ",zippo,&zippo,&zippo[0],zippo[0],&zippo[0][0],zippo[0][0]); printf(" *(*(zippo + 1) + 2) = %d,zippo[1][2] = %d ",*(*(zippo + 2) + 1),zippo[1][2]); printf(" &zippo[0][0] = %p,&zippo[0][1] = %p,&zippo[1][0] = %p,&zippo[1][1] = %p,&zippo[2][0] = %p,&zippo[2][1] = %p,&zippo[3][0] = %p,&zippo[3][1] = %p ",&zippo[0][0],&zippo[0][1],&zippo[1][0],&zippo[1][1],&zippo[2][0],&zippo[2][1],&zippo[3][0],&zippo[3][1]); return 0; }
zippo 和 &zippo[0] 和 &zippo[0][0] 同一个地址 zippo[1][2] 因为C 不检查数组越界,所有zippo[1][2] 相当于 zipp0[2][0]