疑一事 物一事! 2022-08-18 20:31 采纳率: 88.9%
浏览 1818
已结题

was not declared in this scope

问题遇到的现象和发生背景 敲c primer plus 代码的时候
问题相关代码,请勿粘贴截图

char get_choice(void)
{
int ch;
printf("Enter the letter of your choice:\n");
printf("a. advice b.bell\n");
printf("c.count q.quit\n");
ch = get_first();
while ((ch <'a' || ch > 'c' ) && ch != 'q');
{
printf("please respond with a, b, c, or q.\n");
ch = get_first();
}
return ch;
}
char get_first(void)
{
int ch;
ch = getchar();
while (getchar() != '\n')
continue;
return ch;
}

运行结果及报错内容 :第四行 error: `printf' was not declared in this scope

第七行 error: get_first' was not declared in this scope 第十八行 error: getchar' was not declared in this scope

我的解答思路和尝试过的方法

没有思路

  • 写回答

2条回答 默认 最新

  • 快乐鹦鹉 2022-08-18 20:44
    关注

    get_first函数要写在get_choice函数前面,否则在get_choice函数中调用get_first函数时会找不到

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 8月26日
  • 已采纳回答 8月18日
  • 创建了问题 8月18日