用calloc进行C段错误

Aj_*_*_76 1 c segmentation-fault calloc

这两行给了我一个段错误,我无法弄清楚:

int** input;
*input = (int*)calloc(5, sizeof(int));
Run Code Online (Sandbox Code Playgroud)

而已.我理解这一点的方式是,请求内存等于5个int并返回内存地址.将内存地址存储在输入指向的值中.我错过了什么?

Mus*_*usa 7

你永远不会初始化,input所以引用那里发生的任何事情,也许这就是你想要的

int** input;
input = malloc(sizeof(int*));
*input = calloc(5, sizeof(int));
Run Code Online (Sandbox Code Playgroud)