第二scanf函数不工作 [英] Second scanf is not working

查看:152
本文介绍了第二scanf函数不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个c语言code麻烦:

i am having trouble with this c language code:

 char st[2];

 printf("enter first value:");
 scanf("%c", &st[0]);

 printf("enter second value:");
 scanf("%c", &st[1]);

所以,我的电脑没问我要进入第二个价值,我的意思是说,它仅打印第一的printf 语句然后我输入一个字符,然后将其只打印出的第二的printf 语句和程序结束而不采取第二个输入。

So my computer didn't ask me to enter the second value, I mean to say that it only print the first printf statement then I enter a character and then it only prints the second printf statement and program end without taking the second input.

请帮忙。有什么不对的code?

Please help. What's wrong with this code?

- 谢谢提前。

推荐答案

那么它做到了。按ENTER键生成的字符(s)是在已缓冲present。

Well it did. The character(s) produced by the ENTER key is present in the buffer already.

这篇关于第二scanf函数不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆