仅允许1个输入 [英] Allowing 1 input only
本文介绍了仅允许1个输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只是想知道C中是否有任何方法只能从用户那里获得1个输入?
喜欢,
输入一封信:a
输入后,应该是我可以''再用其他字母输入,只有1.
我在想scanf中有一些东西需要稍微修改一下。
谢谢。
char letter;
printf(输入一封信:");
scanf("%c",& letter);
Hi, I just want to know if is there any way in C to get only 1 input from user?
Like,
Enter a letter: a
After inputting a, should be that I can''t anymore type with other letters, only 1.
I''m thinking that there''s something in scanf that needs to be modified a little bit.
Thanks.
char letter;
printf("input a letter: ");
scanf("%c", &letter);
推荐答案
当你说你只允许1个输入时,你的意思是
>
- 忽略输出的其余部分?
- 如果输入更多输出则抛出错误?
- 触摸单个键后,用户''键盘爆炸?
When you say you allow only 1 input, do you mean
- ignore the rest of the output?
- throw an error if more output comes in?
- after touching a single key, the user''s keyboard explodes?
你应该使用cscanf只允许1个输入。
cscanf("%c",& char);
You should use cscanf to allow only 1 input.
cscanf("%c",&char);
感谢您的回复,
@anurag,
谢谢你,只是一个随机的问题,在我的任何其他方式直到需要按回车来验证我的输入?
Thank you for your replies,
@anurag,
Thank you for that, just a random question, any other way where in I still need to press enter to verify my input?
这篇关于仅允许1个输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文