#include <stdio.h> //体会数组和指针的差别
//体会指针的指针的概念
//指针的指针,的值一定是一个地址值,如果不是地址,就说明你可能错了
//指针是一个特殊的变量,有自己的地址,值,和名字
//数组则是一个结构,不是一个变量,因此没有自己的值, 它只是变量的集合
//事实上它只有自己的名字,而地址值是第一个变量的地址值,和其本身无关? int main(){ int a[3] = {1,2,3}; int* pa = a; int (*ppa)[3] = &a; int i = 0; int b = 'A'; int* pi = 0x12FF68; printf("&i is %X \n",&i); printf("*&i is %d \n",*&i); printf("*&b is %c \n",*&b);
printf("*pi is %d \n", *pi); printf("-----------------------------\n"); printf("a value is %X \n",a); printf("pa value is %X \n",pa); printf("ppa value is %X \n",ppa); printf("*ppa value is %X \n",*ppa); printf("-----------------------------\n"); printf("*a value is %d \n",*a); printf("*pa value is %d \n",*pa); printf("*ppa value is %X \n",*ppa); printf("-----------------------------\n"); printf("&a value is %X \n",&a); printf("&pa value is %X \n",&pa); printf("&ppa value is %X \n",&ppa); printf("-----------------------------\n"); for(i = 0; i<3;i++){ printf("a[%d] is : %d \n",i,a[i]); } printf("-----------------------------\n"); for(i = 0; i<3;i++){ printf("*(a+%d) is : %d \n",i,*(a+i)); } printf("-----------------------------\n"); for(i = 0; i<3;i++){ printf("*(pa+%d) is : %d \n",i,*(pa+i)); } printf("-----------------------------\n"); for(i = 0; i<3;i++){ printf("*(*ppa+%d) is : %d \n",i,*(*ppa+i)); } }
|