Calloc a Two-Dimensional Array

前端 未结 4 1884
你的背包
你的背包 2021-02-11 10:40

To make a two dimensional array, I\'m currently using the following:

int * own;

own = (int *)calloc(mem_size, sizeof(int));

for (i=0;i

        
4条回答
  •  轮回少年
    2021-02-11 11:29

    Use:

    int ** own; // int**, not int*
    own = calloc(mem_size, sizeof(int*)); //int*, not int
                                          // And remove the explicit cast.
    

提交回复
热议问题