简单的输出有关问题

简单的输出问题
#include<stdio.h>
void main()
{int state,nl,nc,nw,c;
 nl=nc=nw=0;
 state=0;
 while((c=getchar())!=EOF)
 { nc++; /*统计字符个数*/
  if(c=='\n')
nl++; /*统计行数*/
  if(c==' '||c=='\n'||c=='\t')
state=0; /*判断是否在字母里面*/
  else if(state==0)
  { state=1;
nw++; /*统计单词个数*/
  }
 }
 printf("%d\t%d\t%d\n",nl,nc,nw);
}
这个程序为什么不能输出结果???

------解决方案--------------------
C/C++ code

#include<stdio.h>

void main()
{
    int state,nl,nc,nw,c;
    nl=nc=nw=0;
    state=0;
    while((c=getchar())!='\n')
    { 
        nc++; /*统计字符个数*/
        if(c=='\n')
            nl++; /*统计行数*/
        if(c==' '||c=='\n'||c=='\t')
            state=0; /*判断是否在字母里面*/
        else if(state==0)
        { 
            state=1;
            nw++; /*统计单词个数*/
        }
    }
    printf("%d\t%d\t%d\n",nl,nc,nw);

}

------解决方案--------------------
EOF 定义为-1
'\n' 定义为10