#includevoid swap(int*p1, int*p2){int tmp = *p1;*p1 = *p2;*p2 = tmp;}void main(){int p1 = 1;int p2 = 2;int *num1 = &p1;int *num2 = &p2;swap(num1, num2);printf("p1=%d p2=%d\n", p1, p2);system("pause");}
运行结果:
p1=2 p2=1
请按任意键继续. . .
本文共 295 字,大约阅读时间需要 1 分钟。
#includevoid swap(int*p1, int*p2){int tmp = *p1;*p1 = *p2;*p2 = tmp;}void main(){int p1 = 1;int p2 = 2;int *num1 = &p1;int *num2 = &p2;swap(num1, num2);printf("p1=%d p2=%d\n", p1, p2);system("pause");}
运行结果:
p1=2 p2=1
请按任意键继续. . .
转载于:https://blog.51cto.com/zhangxinbei/1722325