调用函数交换两个值
完整代码
//使用函数实现两个数的交换
#include <stdio.h>
#include<windows.h>
#include<string.h>
void fun1(int* a, int* b){//
int temp = 0;
temp = *a;
*a =* b;
*b = temp;
}
int main(){
int a = 10, b = 20;
fun1(&a,&b);//将空间地址传递给指针变量 a,b的空间
printf("交换后的数为:%d,%d\n", a,b);
system("pause");
return 0;
}