Comparing char in a while loop

浪子不回头ぞ 提交于 2019-12-04 19:47:31

In order to ignore newlines, the scanf should likely be:

scanf(" %c", &input);
       ^

Also you probably want to flush stdout right after that printf:

printf("Enter Input:");
fflush(stdout);

You need to eat a newline char:

scanf("%c", &input);
  while((ch=getchar())!='\n');
Lunar Mushrooms

The error is because the newline character is read from input.

You can refer to this one too : Why doesn't getchar() wait for me to press enter after scanf()?

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!