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

前端 未结 10 1121
甜味超标
甜味超标 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:35

    You receive this error because in C language you are not allowed to use initializers with variable length arrays. The error message you are getting basically says it all.

    6.7.8 Initialization

    ...

    3 The type of the entity to be initialized shall be an array of unknown size or an object type that is not a variable length array type.

提交回复
热议问题