#include<stdio.h>
#include<stdlib.h>
void test(int *p);
int main(){
int *p = NULL;
test(p);
printf("in main, p = %p\n",p);
return 0;
}
void test(int *p){
int i=1;
p = &i;
printf("in test, p = %p\n",p);
}
两次输出的内容是不一样的,在 test 里已经变成了一个有意义的地址,但在 main 中再次打印又变成了一串 0 。
谢谢