原始代码升级版本:
#include <stdio.h> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ int main(int argc, char *argv[]) { int a=114; float b=1.2L; char c=‘A‘; char str[] ="hello world"; printf("&a=%p\n",&a); printf("&b=%p\n",&b); printf("&c=%p\n",&c); printf("&str=%p\n",&str); int *a_ptr=&a; float *b_ptr=&b; char *c_ptr=&c; char *str_ptr=&str; printf("\n\n"); printf("a_prt=%p\n",a_ptr); printf("b_ptr=%p\n",b_ptr); printf("c_ptr=%p\n",c_ptr); printf("str_ptr=%p\n",str_ptr); //定义一个指向指针的指针变量 int **a_ptr_ptr=&a_ptr; printf("\n\n"); printf("a_ptr的地址%p\n",&a_ptr); //a_ptr存的是a的地址,a_ptr_ptr存的是a_ptr的地址; printf("\n\n"); printf("%s","a_ptr存的是a的地址,a_ptr_ptr存的是a_ptr的地址;\n"); printf("a_ptr_ptr的值=%p\n",a_ptr_ptr);//指针的值是一个地址 printf("a_ptr_ptr指向的指针的地址:%p\n",*a_ptr_ptr); printf("a_ptr_ptr指向的指针指指向的值=%d\n",*(*a_ptr_ptr)); return 0; }
输出结果:
&a=000000000062FDFC &b=000000000062FDF8 &c=000000000062FDF7 &str=000000000062FDE0 a_prt=000000000062FDFC b_ptr=000000000062FDF8 c_ptr=000000000062FDF7 str_ptr=000000000062FDE0 a_ptr的地址000000000062FDD8 a_ptr存的是a的地址,a_ptr_ptr存的是a_ptr的地址; a_ptr_ptr的值=000000000062FDD8 a_ptr_ptr指向的指针的地址:000000000062FDFC a_ptr_ptr指向的指针指指向的值=114 -------------------------------- Process exited after 0.0395 seconds with return value 0 请按任意键继续. . .
由于本人是新学者,所以部分内容不保证正确性;
原文:https://www.cnblogs.com/Tpf386/p/13832056.html