统计字符,请大家帮我找找错
程序如下:# include <stdio.h>
void main()
{
int num,alp_a,alp_A,oth;
char a;
num=0;
alp_a=0;
alp_A=0;
oth=0;
printf("本程序负责统计输入的字符的类型\n");
printf("类型有大写字母、小写字母、数字、其他字符\n");
printf("请输入字符,以ESC退出\n");
while((a=getchar()))
{
switch (a)
{
case a>='a' && a<='z':
alp_a ++;
break;
case a>='A' && a<='Z':
alp_A ++;
break;
case a>='0' && a<='9':
num ++;
break;
default:
oth ++;
break;
}
printf("请输入下一个字符:\n");
}
printf("统计结果如下:\n");
printf("小写字母的个数为:%d",alp_a);
printf("大写字母的个数为:%d",alp_A);
printf("数字的个数为:%d",num);
printf("其他的个数为:%d",oth);
}
编译环境:code::blocks
提示错误:
\num_aip\num_alp.c|2|warning: return type of 'main' is not 'int'|
\num_aip\num_alp.c||In function 'main':|
\num_aip\num_alp.c|17|error: case label does not reduce to an integer constant|
\num_aip\num_alp.c|20|error: case label does not reduce to an integer constant|
\num_aip\num_alp.c|23|error: case label does not reduce to an integer constant|
||=== Build finished: 3 errors, 1 warnings ===|