输入10个字符,统计其中英文字母、空格或回车,数字字符和其他字符个数

```

#include
int main()
{
char c;
int i, letter = 0, blank = 0, digit = 0, other = 0;
for (i = 0; i < 10; i++)
{
c = getchar();
if (c >= '0' && c <= '9')
digit++;
else if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'))
letter++;
else if (c == ' ')
blank++;
else if (c == '\n')
blank++;
else
other++;
}
printf("letter = %d, blank = %d, digit = %d, other = %d", letter, blank, digit, other);
return 0;
}

```为什么c=getchar()在for循环里面,这样每一次循环不是都要输入一次c吗?为什么没有?c的输入却只有一次就好,而把c的输入放到循环外面代码就是错的

因为你一次输入好几个字母,内容进的是缓冲区,你一回车,程序才循环从缓冲区取内容。一个一个区的。