c语言isdigit()怎么判断字符是否为阿拉伯数字?isdigit()函数使用方法介绍。引入的头文件:#include <ctype.h>
isdigit()方法的定义:int isdigit(int c);
isdigit()函数介绍:检查参数 c 是否为阿拉伯数字0 到9。
isdigit()返回值:若参数c 为阿拉伯数字,则返回true,否则返回null(0)。
函数使用注意事项:此为宏定义,非真正函数。
c语言isdigit()函数使用实例:找出str 字符串中为阿拉伯数字的字符。
#include <ctype.h> main(){ char str[] = "123@#FDsP[e?"; int i; for(i = 0; str[i] != 0; i++) if(isdigit(str[i])) printf("%c is an digit character\n", str[i]); }
isdigit()函数实例运行结果:
1 is an digit character
2 is an digit character
3 is an digit character