请大家帮忙看看问题出在哪,比较急
写了一段代码,主要是想把一个txt文件的内容输出,然后在统计出现了多少单词,但是现在却只出现txt内的文章内容,却没出现统计,如果有哪为好心人愿意的话,希望可以帮我把程序在改进下,可以输入一个单词,然后显示他出现了多少次,如果嫌麻烦,麻烦帮我修改下这程序,使得可以看到统计数,谢谢大家#include <stdio.h>
#include <memory.h>
int main()
{ FILE *fp;
long number=0;
long zimu=0;
long other=0;
char ch;
if((fp=fopen("Shakespeare-Henry+V.txt","r"))==NULL)
{
printf("cannot open file!\n");
}
while(!feof(fp))
{ch=fgetc(fp);
if(ch>='A'&&ch<='Z'||ch>='a'&&ch<='z')
{zimu++;}
else if(ch>='0'&&ch<='9')
{number++;}
else
{other++;}
}
printf("number=%d zimu=%d other=%d\n",number,zimu,other);
fclose(fp);
{
FILE* pFile = NULL;
char szBuffer[1024];
int nRead = 0;
memset ( szBuffer , 0x0 ,sizeof ( szBuffer ));
pFile = fopen ( "C:\\Documents and Settings\\hopedark\\My Documents\\Shakespeare-Henry+V.txt","r+");
while((nRead = fread ( szBuffer , 1 , sizeof ( szBuffer ), pFile ))>0)
{
printf ("%s\n",szBuffer );
}
fclose ( pFile);
return 0;
}
}