| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1340 人关注过本帖
标题: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
快速回复:scanf语句
数据加载中...
 
   



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

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