想学习双重指针,程序执行时出错,哎!!!1
#include <stdio.h>
static int *g = NULL;
void find(int ** pa)
{
*pa = g;
}
void main()
{
int ** test = NULL;
int a = 99;
g =&a;
find(test);
getchar();
}
错误信息:otto01.exe 中的 0x004113e7 处未处理的异常: 0xC0000005: 写入位置 0x00000000 时发生访问冲突,应该是*pa = g;这行错了。
[解决办法]
*pa = g; 这句有问题!
因为int ** test = NULL; 但是未指定 *test 所以 *pa 不知道指向何处了!