- #include <stdio.h>
- int main()
- {
- int a=0,b=1,c=2,d=3,e=4,f=5;
- int *pa=&a;
- int *pb=&b;
- int *pc=&c;
- int *pd=&d;
- int *pe=&e;
- int *pf=&f;
- int *p[2][3]={{pa,pb,pc},{pd,pe,pf}};
- int *h=p[1][2];
- printf("h=%p\tp[1][2]=%p\tpf=%p\t*h=%d\n",h,p[1][2],pf,*h);
- int arr[2][3]={{1,2,3},{4,5,6}};
- //上面也可以写成int arr[2][3]={1,2,3,4,5,6};
- int (*i)[2][3]=&arr;
- arr[1][2]=9;
- printf("arr[1][2]=%d\n",arr[1][2]);
- (*i)[1][2]=10;
- printf("(*i)[1][2]=%d\tarr[1][2]=%d\n",(*i)[1][2],arr[1][2]);
- //二级指针
- int **p1=&pa;
- printf("**p1=%d\t*p1=%p\tp1=%p\n",**p1,*p1,p1);
- printf("a=%d\t*p1=%p\tp1=%p\n",a,pa,&pa);
- //上面两个输出是等价的
- return 0;
- }
复制代码
|
|