c指针学习
程序员文章站
2022-10-05 07:54:55
#include void main() { int a1=10; int a2=11; int * pa1, * pa2; pa1 = &a1; pa2 = &a2; printf("a1=%d \pa1:%p\n",a1,pa1); printf("a2=%d \pa2:%p ......
#include <stdio.h>
void main()
{
int a1=10;
int a2=11;
int * pa1, * pa2;
pa1 = &a1;
pa2 = &a2;
printf("a1=%d \pa1:%p\n",a1,pa1);
printf("a2=%d \pa2:%p\n",a2,pa2);
*pa1=*pa2;
printf("赋值后\n");
printf("a1=%d\ pa1:%p\n",a1, pa1);
printf("a2=%d\ pa2:%p\n",a2, pa2);
//*pa1=*pa2和a1=a2操作相同
//
pa2=pa1;//把pa1的指针地址复制给了pa2
printf("a1=%d\ pa1:%p\n",a1, pa1);
printf("a2=%d\ pa2:%p\n",a2, pa2);
//指针地址复制,把pa1的指针地址复制给了pa2后现在指针pa1和pa2都指向变量 a1
return 0;
}
上一篇: 微信公众号基本配置
下一篇: JS函数预编译步骤讲解