Malloc compile error: a value of type “int” cannot be used to initialize an entity of type int (*)[30]

前端 未结 6 678
小鲜肉
小鲜肉 2020-12-03 11:56

I must have tried 20 ways of doing this by now. I really need help, no matter what I do i get a error similar to this one.

a value of type \"int\" cannot be          


        
6条回答
  •  醉酒成梦
    2020-12-03 12:11

    To allocate the array:

    int *array = malloc(sizeof(int) * 160 * 10);
    

    Then use code like:

    array[10 * row + column] = value;
    

    (Where row goes from 0 to 159 inclusive and column goes from 0 to 9 inclusive.)

提交回复
热议问题