代码
#include
void swap(int *pa,int *pb)
{
printf("swap is using!\n");
int temp;
temp=*pa;
*pa=*pb;
*pb=temp;
}
int main()
{
int a=10;
int b=20;
printf("a=%d, b=%d\n",a,b);
swap(&a,&b);
printf("After exchanging:\na=%d, b=%d\n",a,b);
return 0;
}
运行结果
a=10, b=20
swap is using!
After exchanging:
a=20, b=10