该功能isalpha()
用于检查字符是否为字母。该函数在“ ctype.h”头文件中声明。它返回一个整数值,如果参数是字母,则返回零。
这是isalpha()
C语言的语法,
int isalpha(int value);
这里,
值-这是整数类型的单个参数。
这是isalpha()
C语言的示例-
#include<stdio.h> #include<ctype.h> int main() { char val1 = 's'; char val2 = '8'; if(isalpha(val1)) printf("The character is an alphabet\n"); else printf("The character is not an alphabet\n"); if(isalpha(val2)) printf("The character is an alphabet\n"); else printf("The character is not an alphabet"); return 0; }
输出结果
这是输出
The character is an alphabet The character is not an alphabet
该功能isdigit()
用于检查字符是否为数字字符。该函数在“ ctype.h”头文件中声明。它返回一个整数值,如果参数为数字,则返回零。
这是isdigit()
C语言的语法,
int isdigit(int value);
这里,
值-这是整数类型的单个参数。
这是isdigit()
C语言的示例,
#include<stdio.h> #include<ctype.h> int main() { char val1 = 's'; char val2 = '8'; if(isdigit(val1)) printf("The character is a digit\n"); else printf("The character is not a digit\n"); if(isdigit(val2)) printf("The character is a digit\n"); else printf("The character is not a digit"); return 0; }
输出结果
这是输出
The character is not a digit The character is a digit