鹦鹉快乐 2022-08-18 20:31 采纳率: 87.5%
浏览 1512
已结题

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日

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效