数字检测--isdigit函数

来源:互联网 发布:淘宝话费充值店利润表 编辑:程序博客网 时间:2024/05/16 17:41

isdigit函数的使用

头文件:”ctyep.h”

函数定义:int isdigit(int c);

函数说明:检查参数 c 是否为阿拉伯数字0 到9。

返回值:若参数c 为阿拉伯数字,则返回ASCII为4的值,否则返回null(0)。

附加说明:此为宏定义,非真正函数。

范例:测试该函数的返回值。

    #include<stdio.h>    #include<ctype.h>    int main()    {        char str[]="1gv568ddfds#%^&*()!#$%@~";        int i;        printf("%s\n",str);        for(i=0;str[i]!='\0';i++)        {             printf("%d\n",isdigit(str[i]),isdigit(str[i]));        }        return 0;    }

执行结果:
4
0
0
4
4
4
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

0 0
原创粉丝点击