为什么我不能用scanf输入字符
为什么这不起作用?我是 C 新手... scanf 函数与其他数据类型一起工作得很好,只是 char 没有给我输入字符的选项
char grade;
printf("Enter your grade: ");
scanf("%c", &grade);
printf("Your grade is %c", grade);
why is this not working? im new to C...
the scanf function works just fine with other data types, its just the char thats not giving me the option to input a character
char grade;
printf("Enter your grade: ");
scanf("%c", &grade);
printf("Your grade is %c", grade);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来在输入字符之前,原始程序中已经输入了其他对象。
在这种情况下,您需要编写
注意转换说明符
%c
之前的空白。它允许跳过空白字符。It seems before entering the character there are inputs of other objects in your original program.
In this case you need to write
Pay attention to the blank before the conversion specifier
%c
. It allows to skip white space characters.