allocate matrix in C

前端 未结 7 1219
别跟我提以往
别跟我提以往 2020-11-29 03:49

i want to allocate a matrix.

is this the only option:

int** mat = (int**)malloc(rows * sizeof(int*))

for (int index=0;index

        
7条回答
  •  再見小時候
    2020-11-29 04:02

    The other answers already covered these, but for completeness, the comp.lang.c FAQ has a relevant entry:

    How can I dynamically allocate a multidimensional array?

提交回复
热议问题