编码如下:
#include <stdio.h>
void swap(int* x,int* y ){
int tmp;
tmp=*x;
*x=*y;
*y=tmp
;
};
int main()
{
int a=4;
int b=5;
printf("befer\n");
printf("a=%d\n",a);
printf("b=%d\n",b);
swap(&a,&b);
printf("after\n");
printf("a=%d\n",a);
printf("b=%d\n",b);
return 0;
}
输出的结果:
befer
a=4
b=5
after
a=5
b=4
标签:tmp,函数,int,after,befer,传递,例子,swap,printf From: https://www.cnblogs.com/gaoyuangaoyuan/p/17440300.html