Here's the struct:
typedef struct state_machine{
char name;
struct state_machine *next0;
struct state_machine *next1;
}state;
and here's me trying to create an array of them
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}};
compiler catches the error on the first line, " state[] states = { "
expected identifier or '(' before '[' token
Change to:
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}};
In C
, the []
should be after the variable name, not after the type.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.