只是课后题,可是错在哪了?
输入一行字符,分别统计出其中英文字母、空格、数字和其他字符的个数。我的代码如下:main()
{
char c[100];
printf("Please input a string less than 100 words:");
scanf("%s",c);
int i, alphabet=0, number=0, space=0, others=0;
for ( i=0; i<100; i++ )
{
if (c[i]==32)
space++;
else if (c[i]>=48 && c[i]<=57)
number++;
else if(c[i]>=65 && c[i]<=90 || c[i]>=97 && c[i]<=122)
alphabet++;
else others++;
}
printf("The string has %d alphabets, %d numbers, % spaces and %d other character.\n", alphabet,number,space,others);
}
一编译,就出现如下错误信息:
expression syntax in function main
菜鸟请高手解决下,谢谢!看在我自学C、自主编的勇气上~~~