c++isdigit函数 |
您所在的位置:网站首页 › isdigit在c语言中的用法 › c++isdigit函数 |
C语言isdigit()函数:判断字符是否为阿拉伯数字头文件: #include 定义函数: int isdigit(int c); 函数说明:检查参数 c 是否为阿拉伯数字0 到9。 返回值:若参数c 为阿拉伯数字,则返回true,否则返回null(0)。 附加说明:此为宏定义,非真正函数。 范例:找出str 字符串中为阿拉伯数字的字符。 #include 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]); } 执行结果: 1 is an digit character 2 is an digit character 3 is an digit character C语言isxdigit()函数:判断字符是否为16进制数字 头文件: #include 定义函数: int isxdigit (int c); 函数说明:检查参数c是否为16 进制数字,只要c为下列其中一个情况就检测成功。 16进制数字:0123456789ABCDEF。 返回值:若参数c 为16 进制数字,则返回非 0,否则返回 0。 附加说明:此为宏定义,非真正函数。 范例:找出字符串str 中为十六进制数字的字符。 #include main(){ char str[] = "123c@#FDsP[e?"; int i; for(i = 0; str[i] != 0; i++) if(isxdigit(str[i])) printf("%c is a hexadecimal digits\n", str[i]); } 执行结果: 1 is a hexadecimal digits 2 is a hexadecimal digits 3 is a hexadecimal digits c is a hexadecimal digits F is a hexadecimal digits D is a hexadecimal digits e is a hexadecimal digits |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |