C scanf() issues?

六眼飞鱼酱① 提交于 2019-12-05 13:29:34

This is a classic newbie error.

scanf("%c",&play);

will read the newline character that is left in the input stream after you read the number in take_guess.

Use

scanf(" %c",&play);

instead.

When you have a whitespace character before %c in the format specifier, the function will read the first non-whitespace character from the input stream. Otherwise, it will read the first available character from the input stream.

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