c语言作业~~帮帮忙啊~~isdigit(int ch) 具体用法

[复制链接]
查看11 | 回复1 | 2009-11-24 14:11:25 | 显示全部楼层 |阅读模式
isdigit 返回非0表示是数字#include #include int main(){ char ch[20]; int sta=0; printf("请输入2个数字:\r\n"); while(1) {scanf("%s",&ch);
for (int l=0;l<strlen(ch);l++)
{ if (isdigit(ch[l])==0) {
printf("//it is wrong try to give two integers:\r\n");
sta=1;
break; }
}if (sta!=1){
if (l<2)
{
printf("//it is wrong try to give two integers:\r\n");
}
else
{
printf("%c%c\r\n",ch[0],ch[1]);
}}sta=0; }return 1;}
回复

使用道具 举报

千问 | 2009-11-24 14:11:25 | 显示全部楼层
用if else ifelse if来判断一下即可 http://baike.baidu.com/view/1275773.htm?fr=ala0//参考百科
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行