[求助关于getchar的问题
#include<stdio.h>
int main()
{
int characters, lines, words;
bool ident=false;
char c;
characters=lines=words=0;
printf("Please input a sencent:\n");
while((c=getchar())!=EOF)
{
++characters;
if(c=='\n') 为什么这里和下面的c若改为c=getchar就不能正常运行呢?
++lines;
if(c==' '||c=='\n'||c=='\t')
ident=false;
else if(ident==false)
{
ident=true;
++words;
}
}
printf("%s%d\n%s%d\n%s%d\n",
"The total character is:",characters,
"The total lines is:",lines,
"The total words is:",words);
return 0;
}