/*ctype.h库中的分类函数
*/
#include <stdio.h>
#include <ctype.h>
int get_char(char *buff)
{
char ch;
int i=0;
while((ch=getchar())!='\n')
{
buff[i++]=ch;
}
return i;
}
void printf_ctype(char ch)
{
if(isalnum(ch))
{
printf("是字母或数字\n");
}
if(isalpha(ch))
{
printf("是英文字母\n");
}
if(isblank(ch))
{
printf("是'\t'或' '\n");
}
if(iscntrl(ch))
{
printf("是控制字符\n");
}
if(isdigit(ch))
{
printf("是数字\n");
}
if(isgraph(ch))
{
printf("是可显示字符\n");
}
if(islower(ch))
{
printf("是小写字母\n");
}
if(isprint(ch))
{
printf("是可打印字符\n");
}
if(ispunct(ch))
{
printf("属于isgraph范围\n");
}
if(isspace(ch))
{
printf("是' '\t' '\n' '\v' 'f' 'r'\n");
}
if(isupper(ch))
{
printf("是大写英文字符\n");
}
if(isdigit(ch))
{
printf("是16进制的数学字符\n");
}
if(tolower(ch))
{
printf("将字符转为小写英文字母\n");
}
if(toupper(ch))
{
printf("将字符转为大写英文字母\n");
}
}
int main(void)
{
char buff[100];
int len=0;
len=get_char(buff);
if(len!=0)
{
for(int i=0;i<len;i++)
{
printf_ctype(buff[i]);
printf("\n");
}
}
return 0;
}
标签:ch,函数,int,ctype,char,库中,printf,buff
From: https://www.cnblogs.com/yesiming/p/18331280