main() {
int a,b;
int point_1,point_2;
scanf("%d%d",&a,&b);
point_1 = &a;
point_2 = &b;
printf("%d,%d\n",a,b);
compositor(point_1,point_2);
printf("%d,%d",a,b);
}
compositor(int *p1,int *p2) {
int temp;
temp = *p1;
*p1 = *p2;
*p2 = temp;
}
以上程序可以交换point_1,point_2所指的东西,为什么不把compositor改成
compositor(int *p1,int *p2) {
int temp;
temp = p1;
p1 = p2;
p2 = temp;
}
就不行呢?其实也是交换了point_1,point_2的地址啊!