这还是相当于交换了实参啊
以下是引用吹水佬在2017-1-8 16:49:54的发言:
#include <stdio.h>
void swap(int **p1, int **p2)
{
int *t;
t = *p1;
*p1 = *p2;
*p2 = t;
}
main()
{
int a=1, b=2;
int *p1=&a, *p2=&b;
printf("%d %d\n", *p1, *p2);
swap(&p1, &p2);
printf("%d %d\n", *p1, *p2);
}
#include <stdio.h>
void swap(int **p1, int **p2)
{
int *t;
t = *p1;
*p1 = *p2;
*p2 = t;
}
main()
{
int a=1, b=2;
int *p1=&a, *p2=&b;
printf("%d %d\n", *p1, *p2);
swap(&p1, &p2);
printf("%d %d\n", *p1, *p2);
}
还没搞懂,我再看看
[此贴子已经被作者于2017-1-8 17:03编辑过]