注意:是传送地址,才能改变原数据!!!
#include<stdio.h>
void swap(int* pa, int* pb)
{
int z = 0;
z = *pa;
*pa = *pb;
*pb = z;
return 0;
}
int main()
{
int a = 210;
int b = 320;
printf("%d %d\n", a, b);
swap(&a,&b);
printf("%d %d", a, b);
return 0;
}
注意:是传送地址,才能改变原数据!!!
#include<stdio.h>
void swap(int* pa, int* pb)
{
int z = 0;
z = *pa;
*pa = *pb;
*pb = z;
return 0;
}
int main()
{
int a = 210;
int b = 320;
printf("%d %d\n", a, b);
swap(&a,&b);
printf("%d %d", a, b);
return 0;
}