gpt4 book ai didi

c - 结构数组

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:29:01 26 4
gpt4 key购买 nike

结构如下:

typedef struct state_machine{
char name;
struct state_machine *next0;
struct state_machine *next1;
}state;

这是我尝试创建一个数组

state[] states = {
{'A', state+3, state+4},
{'B', state, state+5},
{'C', state+4, state },
{'D', state+5, state+6},
{'E', state+1, state+7},
{'F', state+7, state+3},
{'G', state+2, state+6},
{'F', state+6, state+1}};

编译器在第一行捕获错误,"state[] states = { "

预期标识符或“[”标记前的“(”

最佳答案

更改为:

state states[] = {
{'A', states+3, states+4}, //You probably meant states, since state is a type
{'B', states, states+5},
{'C', states+4, states },
{'D', states+5, states+6},
{'E', states+1, states+7},
{'F', states+7, states+3},
{'G', states+2, states+6},
{'F', states+6, states+1}};

C 中,[] 应该在变量名之后,而不是在类型之后。

关于c - 结构数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22100704/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com