fflush和stdin [英] fflush and stdin

查看:86
本文介绍了fflush和stdin的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请修复错误... ??


#include< stdio.h>


int main()

{

int i;

char j;

printf("输入任意数字...(1或2):);

scanf("%d"& i);

switch(i)

{

案例1:

printf("输入任何字母:");

fflush(stdin);

scanf("%c"& j);

switch(j)

{

case''a'':

printf(赢家从不

退出...);

休息;

case' 'b'':

printf(Quitters never

win ...);

break;

}

休息;

案例2:

printf(" \ nFailure是成功的支柱......);

}

返回0;

}


它没有显示所需的o / G在GCC中运行时。谢谢

please fix the bugs...??

#include <stdio.h>

int main()
{
int i;
char j;
printf("Enter any number ...(1 or 2) : ");
scanf("%d",&i);
switch(i)
{
case 1:
printf("Enter any alphabet : ");
fflush(stdin);
scanf("%c",&j);
switch(j)
{
case ''a'':
printf("Winners never
quit...");
break;
case ''b'':
printf("Quitters never
win...");
break;
}
break;
case 2:
printf("\nFailure is pillar of success..");
}
return 0;
}

It doesn''t show the required o/p when run in GCC. Thank You

推荐答案

asit写道:

....
asit wrote:
....

fflush(stdin);
fflush(stdin);



7.19.5.2,描述fflush(流),说:


"如果流指向输出流或一个更新流,其中没有输入

最近的操作,fflush函数导致该流的任何

未写入数据被传送到主机环境

写入文件;否则,行为是未定义的。


现在仔细考虑stdin和短语输出流。

7.19.5.2, descring fflush(stream), says:

"If stream points to an output stream or an update stream in which the
most recent operation was not input, the fflush function causes any
unwritten data for that stream to be delivered to the host environment
to be written to the file; otherwise, the behavior is undefined."

Now think carefully about "stdin" and the phrase "output stream".


1月14日晚上10点33分,jameskuy ... @ verizon.net写道:
On Jan 14, 10:33 pm, jameskuy...@verizon.net wrote:

asit写道:


...
asit wrote:

...

fflush(stdin);
fflush(stdin);



7.19.5.2,描述fflush(流),说:


"如果流指向输出流或一个更新流,其中没有输入

最近的操作,fflush函数导致该流的任何

未写入数据被传送到主机环境

写入文件;否则,行为是未定义的。


现在仔细考虑stdin和短语输出流。


7.19.5.2, descring fflush(stream), says:

"If stream points to an output stream or an update stream in which the
most recent operation was not input, the fflush function causes any
unwritten data for that stream to be delivered to the host environment
to be written to the file; otherwise, the behavior is undefined."

Now think carefully about "stdin" and the phrase "output stream".



仍然无法修复它。请帮帮我。


still i can''t fix it. please help me.


文章< 61 ************************** ******** @ v46g2000hsv。 googlegroups.com>,

asit< li ***** @ gmail.comwrote:
In article <61**********************************@v46g2000hsv. googlegroups.com>,
asit <li*****@gmail.comwrote:

>现在仔细考虑stdin和短语输出流。
>Now think carefully about "stdin" and the phrase "output stream".


>仍然无法修复它。请帮我。
>still i can''t fix it. please help me.



fflush做什么?如果你不知道,请查阅。怎么可能与你的问题有关?

- Richard

-

:wq

What does fflush do? Look it up if you don''t know. How might it be
relevant to your problem?

-- Richard
--
:wq


这篇关于fflush和stdin的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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