为什么printf(" ...")语句执行2次......? [英] why printf("...") statement is executing 2 times...?

查看:141
本文介绍了为什么printf(" ...")语句执行2次......?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我写了一个c-progam代码,用于打印用户是否输入了数字或字符。


代码为: -

Hi,

I wrote a c-progam code , for to print whether the user has entered the digit or charater.

The code is :-

展开 | 选择 | Wrap | 行号

推荐答案

展开 | 选择 < span class =codeDivider> | Wrap | 行号




使用getchar()它的bcz ur 。输入数字或字母后,按下输入键。这将作为字符,循环将运行两次。所以输入你的选择将打印两次.plz执行下面给出的修改程序。你会明白的更好。


不允许喂食
Hi
Its bcz u r using getchar(). After entering number or alphabet u wl press ente key.This wil take as char and the loop wil run twice. so "Enter your choice" wil be printed twice.plz execute d modified program given below. u wil understand better.


spoonfeeding not allowed



你好/>
使用getchar()来表示它的bcz。输入数字或字母后,按下输入键。这将作为字符,循环将运行两次。所以输入你的选择将打印两次.plz执行下面给出的修改程序。你会明白的更好。



不允许使用勺子
Hi
Its bcz u r using getchar(). After entering number or alphabet u wl press ente key.This wil take as char and the loop wil run twice. so "Enter your choice" wil be printed twice.plz execute d modified program given below. u wil understand better.


spoonfeeding not allowed



实际上这个问题没有任何意义使用getchar()。它就是编写程序的方式。在第一次执行时,它要求用户输入您的选择两次。

Actually the problem doesn''t have anything to do with getchar(). Its just the way the program is written. On the first execution it asks the user to Enter your choice twice.


这篇关于为什么printf(&quot; ...&quot;)语句执行2次......?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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