MultiDimensional Array in Objective c

前端 未结 3 799
臣服心动
臣服心动 2021-01-03 15:43

EveryBody..

i want to create one 8*8 dimensional array in objective c..

(
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0         


        
3条回答
  •  攒了一身酷
    2021-01-03 16:00

    In C:

    int **array = (int**)calloc(8, sizeof(int*));
    for (int i=0; i<8; i++) array[i] = (int*)calloc(8, sizeof(int));
    // use your array
    // cleaning:
    for (int i=0; i<8; i++) free(array[i]);
    free(array);
    

提交回复
热议问题