数组指针和数组变量之间的关系
coderzhouyu
#include<stdio.h>
#define LHEIGHT 20
#define LWIDTH 12
int main()
{
int temp[5] = {1,2,3,4,5};
// 指向数组的指针 类型是int *[5]
int (*p)[5] = &temp;
// temp 实际上是指向第一个元素的地址 即 int *
printf("%p\n",temp);
printf("%p\n",&temp[0]);
// 取出指向数组的指针地址
printf("%p\n",*p);
// 指向数组的指针 虽然地址和*p一样但是实际上类型不同 *p 是 int * p是 int (*)[5]
printf("%p\n",p);
for (int i = 0; i < 5; i++)
{
printf("%d ",*(*p+i));
}
int temp1[][3] = {
{1,2,3},
{4,5,6}
};
// 这两个是一致的 temp1 实际上就是 int (*)[3] 类型的一个指针
int (*p1)[3] = temp1;
}