EOF到底是什么?
#include <stdio.h>
#include <stdlib.h>
int main()
{
int c,nb,nt,n1;
nb=0;
nt=0;
n1=0;
while ((c=getchar())!=EOF)
{
if (c== ' ')
++nb;
if (c== '\t ')
++nt;
if (c== '\n ')
++n1;
}
printf ( "%d%d%d\n ",nb,nt,n1);
system ( "PAUSE ");
return 0;
}
一直没真正理解EOF到底是什么,这以上这个程序中输入什么能让他统计出结果?
[解决办法]
怎样定义文件结束标志?以上程序运行后,一直要求输入字符,怎样才能得到结果呢?指点下!
不是要输入-1才能停下来吧!
————————————————————————————————————————
ctrl+z