什么是字符分析函数?使用 C 语言程序进行说明。
字符分析和转换函数
“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("Enter the character : ");
//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
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP