//我写的 你看看对不对,我的是统计一个文件中的单词个数
#include
#include
#define IN 1
#define OUT 0
int main()
{
char szFilename[256];
FILE *fp;
printf("input the file:");
scanf("%s",szFilename);
if((fp=fopen(szFilename,"r"))==NULL)
{
printf("the file don't exist!");
exit(1);
}
int flag=OUT;
int c;
int nw=0;
while((c=fgetc(fp))!=EOF)
{
if(c==' ')
{
flag=OUT;
}
else if(OUT==flag)
{
flag=IN;
nw++;
}
}
printf("THe num is:%d\n",nw);
return 0;
}