我正在尝试在 arduino 上写一个 5 个问题的测验,其中包含三个可能的答案并在最后输出一个分数。我试图把它写在它问第一个问题的地方,在有人输入他们的答案后,它会转到下一个问题。我在“。”之前的初始化程序有问题。令牌错误消息。你能帮助我吗?
`typedef struct{
char question[];
char answer1[];
char answer2[];
char answer3[];
char correct_answer;
}question_t;
question_t questions[] = {questions[0], questions[1], questions[2], questions[3], questions[4]};
question_t questions[0].question = "1. What is the capital of Illinois?";
question_t questions[0].answer1 = "a) Chicago";
question_t questions[0].answer2 = "b) Springfield";
question_t questions[0].answer3 = "c) Carbondale";
question_t questions[0].correct_answer = 'b';
question_t questions[1].question = "2. Who is the governor of Wisconsin?";
question_t questions[1].answer1 = "a) Scott Walker";
question_t questions[1].answer2 = "b) Clay Matthews";
question_t questions[1].answer3 = "c) Cole Nebel";
question_t questions[1].correct_answer = 'a';
question_t questions[2].question = "3. Where is MSOE?";
question_t questions[2].answer1 = "a) Memphis";
question_t questions[2].answer2 = "b) Manitowoc";
question_t questions[2].answer3 = "c) Milwaukee";
question_t questions[2].correct_answer = 'c';
question_t questions[3].question = "4. Why is Justin Bieber in jail?";
question_t questions[3].answer1 = "a) DUI";
question_t questions[3].answer2 = "b) bad music";
question_t questions[3].answer3 = "c) looking like Miley Cyrus";
question_t questions[3].correct_answer = 'a';
question_t questions[4].question = "5. Who is Jim Jefferies?";
question_t questions[4].answer1 = "a) actor";
question_t questions[4].answer2 = "b) singer";
question_t questions[4].answer3 = "c) comedian";
question_t questions[4].correct_answer = 'c';
int score;
int i;
char c;
char read_user_input(char c);
void output_question(uint8_t i);
void output_score(void);
loop()
{
init();
score=0:
uint8_t i;
i=0;
while(i<5)
{
output_question(i);
c=read_user_input();
if(c==questions[i].correct_answer)
{
score=score+20;
}i++;
}
Serial.print(output_score());
}
void init(void)
{
questions[5]:
}`