标题:scanf语句
取消只看楼主
leolhc
Rank: 1
等 级:新手上路
帖 子:21
专家分:0
注 册:2006-1-17
 问题点数:0 回复次数:1 
scanf语句
#include <stdio.h>
main()
{
int n;
do
{
printf("please input a odd number.\n");
scanf("%d",&n);
}while((n>15)||(n<3)||(n%2==0));
getch();
}


以上程序,当我输入非数字的字符时,结果是执行无限循环的printf("please input a odd number.\n");根本不再做scanf的动作,为什么?

[此贴子已经被作者于2006-2-22 10:00:46编辑过]

搜索更多相关主题的帖子: scanf 语句 input number please 
2006-02-22 09:44
leolhc
Rank: 1
等 级:新手上路
帖 子:21
专家分:0
注 册:2006-1-17
得分:0 
I found the answer myself.
reason:
The next character read can't be converted under the current format (for example, an A when the format is decimal).
2006-02-22 10:16



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-46564-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.187381 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved