ctype.h是C标准函数库中的头文件,定义了一批C语言字符分类函数(C character classification functions),用于测试字符是否属于特定的字符类别,如字母字符、控制字符等等。既支持单字节(Byte)字符,也支持宽字符。
isalpha
函数名称: isalpha
函数原型: int isalpha(char ch);
函数功能: 检查ch是否是字母.
函数返回: 是字母返回非0(在vs2015中为2) ,否则返回 0.
参数说明:
所属文件 <ctype.h>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include<stdio.h>
#include<ctype.h>
int
main()
{
char
ch1=
'*'
;
char
ch2=
'a'
;
if
(
isalpha
(ch1)!=0)
printf
(
"%c is the ASCII alphabet\n"
,ch1);
else
printf
(
"%c is not the ASCII alphabet\n"
,ch1);
if
(
isalnum
(ch2)!=0)
printf
(
"%c is the ASCII alphabet\n"
,ch2);
else
printf
(
"%c is not the ASCII alphabet\n"
,ch2);
return0;
}
tolower
函数名称: tolower
函数原型: int tolower(int ch);
函数功能: 将ch
字符转换为小写字母
函数返回: 返回ch所代表的字符的小写字母
参数说明:
所属文件: <ctype.h>
1
2
3
4
5
6
7
8
9
10
11
12
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
intmain()
{
charx=
'a'
,y=
'b'
,z=
'A'
,w=
'*'
;
printf
(
"Character%ctoloweris%c\n"
,x,
tolower
(x));
printf
(
"Character%ctoloweris%c\n"
,y,
tolower
(y));
printf
(
"Character%ctoloweris%c\n"
,z,
tolower
(z));
printf
(
"Character%ctoloweris%c\n"
,w,
tolower
(w));
return0;
}