Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当我在我的结构中初始化这个数组时。我收到错误消息 - 语法错误:'{'。'{' 之前的意外标记;跳过明显的函数体。
int array[8][2] = {{3,6},{3,10},{3,14},{8,4}, {8,8},{8,12},{8,16},{12,2}};
当我从教科书中复制语法时,我不确定出了什么问题。
声明为 typedef struct _array *Array;
您不能在结构声明中初始化变量,无论是数组还是 int。但是,您可以在结构初始化中初始化数组。
struct foo { int x; int array[8][2]; }; struct foo foovar = {1, {{3,6},{3,10},{3,14},{8,4}, {8,8},{8,12},{8,16},{12,2}}};