求教:单词计数程序无法输出,求大神帮忙看看~~
#include "stdafx.h"#include "stdio.h"
int main(void)
{
int c,nline=0,nwrite=0,nchar=0,state=0;
while((c=getchar())!=EOF)
{
++nchar;
if(c=='\n')
++nline;
if(c==' '||c=='\n'||c=='\t')
state=1;//在单词外//
else if(state==0)
{
++nwrite;
state=0;//在单词内//
}
}
printf("the number of line:%d\n",nline);
printf("the number of write:%d\n",nwrite);
printf("the number of char:%d\n",nchar);
return 0;
}