您的位置:首页 > 其它

交换两个int指针所指向的内存地址。

2018-02-17 23:05 113 查看
#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;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐