刚学c语言新手求助
题目:输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数
#include<stdio.h>
#include<stdlib.h>
main()
{
int letters=0,space=0,digit=0,others=0;
char ch;
printf("please input a string:\n");
while((ch=getchar()!='\n'))
{
if((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z'))
letters++;
else if(ch==' ')
space++;
else if(ch>='0'&&ch<='9')
digit++;
else
others++;
}
printf("The number of English characters,spaces,numbers,other characters are: %d %d %d %d\n",letters,space,digit,others);
system("pause");
return 0;
}
这个运行后总是有问题,我想不出原因,请各位大侠指点