代码拉取完成,页面将自动刷新
#include <iostream>
#include <malloc.h>
using namespace std;
#include <string.h>
/* 常量 */
#define MAX 3
/* 函数声明 */
void swapAddressByPoint(int *a, int *b);
int main(){
int a = 1;
int b =2;
swapAddressByPoint(&a, &b);
cout << "\n\t'a':" << a << "\t'b'" << b << endl;
}
void swapAddressByPoint(int *a, int *b){
int *temp = (int*)malloc(sizeof(int));
cout << "initialize malloc address for 'temp' (which) is:" << temp << "\n";
temp = a;
cout << "swap from variable 'a' point, now address for 'temp' (which) is:" << temp << "\n";
a = b;
b = temp;
cout << "swap address both 'a' point and 'b' point, now address for 'a' is:" << a << "\tand 'b' is" << b << endl;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。