# include <iostream>
# include <string.h>
using namespace std;
int main()
{
void swap(int *p1,int *p2);
int a=1,b=2,*p1=&a,*p2=&b;
swap(p1,p2);
cout<<*p1<<endl;
return 0;
}
void swap(int *p1,int *p2)
{
int *temp;
temp=p1;
*p1=*p2;
*p2=*temp;
}
# include <iostream>
# include <string.h>
using namespace std;
int main()
{
void swap(int *p1,int *p2);
int a=1,b=2,*p1=&a,*p2=&b;
swap(p1,p2);
cout<<*p1<<endl;
return 0;
}
void swap(int *p1,int *p2)
{
int *temp;
temp=p1;
p1=p2;
p2=temp;
}
为何第一个输出结果是2,第二个输出结果是1