background image

 

 

isascii(测试字符是否为 ASCII 

 

码字符)

 

相关函数 iscntrl

 

表头文件 #include <ctype.h>

 

定义函数 int isascii(int c);

 

函数说明 检查参数 c 是否为 ASCII 码字符,也就是判断 c 的范围是否在 0 到 127 之间。

 

返回值 若参数 c 为 ASCII 码字符,则返回 TRUE,否则返回 NULL(0)。

 

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

 

范例 /* 判断 int i 是否具有对映的 ASCII 码字符*/

#include<ctype.h>

main()
{

int i;
for(i=125;i<130;i++)

if(isascii(i))
printf("%d is an ascii character:%c\n",i,i);

else
printf("%d is not an ascii character\n",i);

}

 

执行 125 is an ascii character:}

126 is an ascii character:~
127 is an ascii character:

128 is not an ascii character
129 is not an ascii character

 

 

iscntrl(测试字符是否为 ASCII 

 

码的控制字符)

 

相关函数 isascii

 

表头文件 #include <ctype.h>

 

定义函数 int iscntrl(int c);

 

函数说明 检查参数 c 是否为 ASCII 控制码,也就是判断 c 的范围是否在 0 到 30 之间。

 

返回值 若参数 c 为 ASCII 控制码,则返回 TRUE,否则返回 NULL(0)。

 

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

 

 

isdigit

 

(测试字符是否为阿拉伯数字)

 

相关函数 isxdigit

 

表头文件 #include<ctype.h>

 

定义函数 int isdigit(int c)

 

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

 

返回值 若参数 c 为阿拉伯数字,则返回 TRUE,否则返回 NULL(0)。

 

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

 

范例 /* 找出 str 字符串中为阿拉伯数字的字符*/

#include<ctype.h>

main()
{

char str[]="123@#FDsP[e?";
int i;

for(i=0;str[i]!=0;i++)