// // main.c // C11-指针2 // 已经快被自己搞吐了 // Created by apple on 15/1/8. // Copyright (c) 2015年 itcast. All rights reserved. //
#include <stdio.h>
int main(int argc, const char * argv[]) {
//定义二维数组arr int arr[3][4]={1,2,3,4,5,6,7,8,9,10,11,12}; //定义指针数组p[3],该指针数组存放的是每一个元素是一个数组指针 (列指针) int *p[3]={arr[0],arr[1],arr[2]}; //定义一个二维数组指针,(行指针) int (*q)[4]; q = arr; //定义一个普通的二级指针 int *r = arr;
//p=arr=&arr[0]=q //p+1=arr+1=&arr[1]=q+1 //p+2=arr+2=&arr[2]=q+2 printf("%d\t",**arr); //1 printf("%d\t",**p); //1 printf("%d\t",*(p[0])); //1 printf("%d\t",(*q)[0]); //1 printf("%d\n",*r); //1
printf("%d\t",**(arr+1)); //5 printf("%d\t",**(p+1)); //5 printf("%d\t",*(p[1])); //5 9同理 printf("%d\t",*(q+1)[0]); //5 printf("%d\n",*(r+4)); //5
printf("%d\t",*((*arr)+1)); //2 printf("%d\t",*(*(p)+1)); //2 printf("%d\t",*(p[0]+1)); //2 printf("%d\t",(*q)[1]); //2 printf("%d\n",*(r+1)); //2
printf("%d\t",*(*(arr+1)+1)); //6 printf("%d\t",*(*(p+1)+1)); //6 printf("%d\t",*(p[1]+1)); //6 printf("%d\t",(*(q+1))[1]); //6 printf("%d\n",*(r+5)); //6
return 0; }
|