如何判断输入字符种类

2018-03-30  本文已影响0人  I_can_code

include<stdio.h>

int main()
{
char a;
printf("Input simple:\n");
scanf("%c",&a);
if(a>=48&&a<=58)
printf("It is a digit character.\n");
else if(a>=65&&a<=90||a>=97&&a<=122)
printf("It is an English character.\n");
else
printf("It is other character.\n");
return 0;
}
0-9对应的ASCII码:48-58
A-Z对应的ASCII码 : 65-90
a-z对应的ASCII码 : 97-122

上一篇下一篇

猜你喜欢

热点阅读