用一个 指针 指向 指针
1 int num=10; 2 int *p1=# 3 int *p2=p1; 4 5 printf("num1:%d\n",num); 6 printf("*p1-1:%d\n",*p1); 7 printf("*p2-1:%d\n",*p2); 8 9 *p1=100; 10 printf("num2:%d\n",num); 11 printf("*p1-2:%d\n",*p1); 12 printf("*p2-2:%d\n",*p2);
运行结果如图:
逻辑结构如图:
用一个 指针的指针 指向 指针
1 int num=10; 2 int *p1=# 3 int **p2=&p1; 4 5 printf("num-add:%d\n",&num); 6 printf("p1-add:%d\n",&p1); 7 printf("p2-add:%d\n",&p2); 8 printf("p2:%d\n",p2);//p1的地址 9 printf("*p2:%d\n",*p2);//p1的地址上的值->num的地址 10 printf("**p2:%d\n\n",**p2);//num的地址上的值->num的值 11 12 printf("num1:%d\n",num); 13 printf("*p1-1:%d\n",*p1); 14 printf("**p2-1:%d\n",**p2); 15 16 *p1=100; 17 printf("num2:%d\n",num); 18 printf("*p1-2:%d\n",*p1); 19 printf("**p2-2:%d\n",**p2);
运行结果如图:
逻辑结构如图: