交换两个数,为什么不能用*t来做为临时变量。
#include <stdio.h>
/*************found**************/
void fun(int *x,int *y)
{ int *t;
/*************found**************/
*t=*x;*x=*y;*y=*t;
}
void main()
{ int a,b;
a=8;
b=3;
fun(&a, &b);
printf("%d %d\n ", a,b);
}
#include <stdio.h>
/*************found**************/
void fun(int *x,int *y)
{ int t;
/*************found**************/
t=*x;*x=*y;*y=t;
}
void main()
{ int a,b;
a=8;
b=3;
fun(&a, &b);
printf("%d %d\n ", a,b);
}
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |