“ ctype.h”库中的预定义函数用于分析字符输入并将其转换。
序号 | 功能 | 描述 |
---|---|---|
1 | isalpha() | 是否有字母 |
2个 | isdigit() | 是否有数字 |
3 | isspace() | 空格,换行或制表符 |
4 | ispunct() | 是否有特殊符号 |
5 | slower() | 小写字母 |
6 | isupper() | 大写字母 |
7 | isalphanumeric() | 是否使用字母/数字 |
功能 | 描述 |
---|---|
tolower() | 将大写字母转换为小写 |
toupper() | 将小写字母转换为大写 |
让我们看一个演示字符分析和转换功能的程序-
#include<stdio.h> #include<ctype.h> void main(){ //Initializing compile time character variable// char variable = 'A'; //Reading User I/P// //printf("输入字符: "); //scanf("%c",variable); //Using character analysis function & printing O/p// if (isalpha(variable)){ printf("The character entered is :%c, an alphabet",variable); }else{ printf("The character entered is not an alphabet"); } }输出结果
The character entered is :A, an alphabet