isxdigit
测试字符是否为16进制数字
相关函数
isalnum,isdigit
表头文件
#include<ctype.h>
定义函数
int isxdigit(int c)
函数说明
检查参数c是否为16进制数字,只要c为下列其中一个情况则返回TRUE。16进制数字:0123456789ABCDEF。
返回值
若参数c为16进制数字,则返回TRUE,否则返回NULL(0)。
附加说明
此为宏定义,非真正函数。
范例
/*找出字符串str中为十六进制数字的字符*/
#include <ctype.h>
#include <stdio.h>
int main()
{
char str[] = "123c@#FDsP[e?";
for(int i = 0; str[i] != 0 ;i++)
if(isxdigit(str[i]))
printf("%c is a hexadecimal digit\n",str[i]);
return 0;
}
执行
1 is a hexadecimal digit
2 is a hexadecimal digit
3 is a hexadecimal digit
c is a hexadecimal digit
F is a hexadecimal digit
D is a hexadecimal digit
e is a hexadecimal digit