#include<stdio.h>
int add(int a,int b){
return a+b;
}
int main(){
freopen("out.txt","w",stdout);
int a;
int * pa;
int **ppa;
a = 10;
pa = & a;
ppa = &pa;
printf("==========================\n");
printf("a=%d\n",a);
printf("&a=%x\n",&a);
printf("(pa = & a)pa=%x\n",pa);
printf("pa+1=%x\n",pa+1);
printf("&pa=%x\n",&pa);
printf("*pa=%d\n",*pa);
printf("(ppa = &pa)ppa=%x\n",ppa);
printf("*ppa=%x\n",*ppa);
printf("**pa=%d\n",**ppa);
printf("&ppa=%x\n",&ppa);
printf("==========================\n");
printf("add()中的add值=%x\n",add);
printf("add()中的&add值=%x\n",&add);
int (*pfunc1)(int,int);
pfunc1 = &add;
printf("pfunc1=&add pfunc1=%x\n",pfunc1);
pfunc1 = add;
printf("pfunc1=add pfunc1=%x\n",pfunc1);
printf("add(1,2)=%d,pfunc1(1,2)=%d,(*pfunc1)(1,2)=%d\n",add(1,2),pfunc1(1,2),(*pfunc1)(1,2));
printf("==========================\n");
printf("==========================\n");
return 0;
}
指针例子
最新推荐文章于 2022-01-26 18:13:37 发布