typedef struct _t
{
int** p;
}T;
void test(int **p)
{
int** t = (int **)realloc(p,80000);
p = t;
cout << p << endl;
}
void test2(T *n)
{
int** t = (int **)realloc(n->p,80000);
n->p = t;
cout << n->p << endl;
}
int main()
{
int **p = (int **)malloc(4);
cout << p << endl;
test(p);
cout << p << endl;
T n;
int **p2 = (int **)malloc(4);
n.p = p2;
//n.p = (int **)malloc(4);
cout <<n.p << endl;
test2(&n);
cout << n.p << endl;
return 0;
}
//结果
0x7fcef74029c0
0x7fcef7805000
0x7fcef74029c0
0x7fcef74029c0
0x7fcef7818a00
0x7fcef7818a00
备份地址: 【结构体中包裹变量实现改值】