#include<stdio.h>
void change(int *p){
int val = 5;
printf("%p\n", p);
*p = val;
printf("%p\n", p);
p = &val;
printf("%p\n", p);
}
int main(){
int val = 4;
int *p = &val;
change(p);
printf("%d\n", *p);
printf("%p\n", p);
return 0;
}
运行结果:
0x7fffdb8192a4
0x7fffdb8192a4
0x7fffdb81928c
5
0x7fffdb8192a4