#include<string>
#include<iostream>
using namespace std;
void* exchange(int **a, int **b);
void* exchange(int **a, int **b)
{
int *temp = *a;
*a=*b;
*b = temp;
return 0;
}
int main()
{
int x = 0, y = 5;
int *a = &x, *b = &y;
cout << a <<'\t'<< b << endl;
exchange(&a, &b);
cout << a << '\t'<< b << endl;
system("pause");
return 0;
}
交换两个int指针所指向的内存地址。
最新推荐文章于 2024-01-28 17:26:35 发布