|
标准库
1 字符测试函数
1> 函数原型均为int isxxxx(int)
2> 参数为int, 任何实参均被提升成整型
3> 只能正确处理处于[0, 127]之间的值
isalpha 'A'~'Z', 'a'~'z'
isdigit '0'~'9'
isxdigit '0'~'9', 'A'~'F', 'a'~'f'
isalnum isalpha || isdigit
islower 'a'~'z'
isupper 'A'~'Z'
isspace
9 '\t' (tab: 水平制表位)
10 '\n' (line feed: 换行)
11 '\v' (home: 垂直制表位)
12 '\f' (form feed: 换页)
13 '\r' (carriage return: 回车)
32 ' ' (space: 空格)
isgraph 33~126
isprint isgraph || ' '
ispunct isgraph && !isalnum
iscntrl 0~31, 127
2 字符映射函数
1> 函数原型为int toxxxx(int)
2> 对参数进行检测, 若符合范围则转换, 否则不变
int tolower(int); 'A'~'Z' ==> 'a'~'z'
int toupper(int); 'a'~'z' ==> 'A'~'Z'
3 附测试代码
#include
#include
char (* isxx_name[]) =
{
"isalpha",
"isdigit",
"isxdigit",
"isalnum",
"islower",
"isupper",
"isspace",
"isgraph",
"isprint",
"ispunct",
"iscntrl"
};
int (* isxx_list[])(int) =
{
isalpha,
isdigit,
isxdigit,
isalnum,
islower,
isupper,
isspace,
isgraph,
isprint,
ispunct,
iscntrl
};
int main()
{
int i, k;
for (i=0; i |
|