C compile error: “Variable-sized object may not be initialized”

前端 未结 10 1265
甜味超标
甜味超标 2020-11-22 07:22

Why do I receive the error \"Variable-sized object may not be initialized\" with the following code?

int boardAux[length][length] = {{0}};
10条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-22 07:38

    After declaring the array

    int boardAux[length][length];
    

    the simplest way to assign the initial values as zero is using for loop, even if it may be a bit lengthy

    int i, j;
    for (i = 0; i

提交回复
热议问题