统计文件中字符个数,编译没问题 统计的有问题 请各位大神看看
#include<stdio.h>#include<stdlib.h>
int main()
{
FILE *fp;
int num=0;
char filename[10];
printf("please files name:\n");
gets(filename);
if((fp=fopen(filename,"r"))==NULL)
{
printf("open files error!");
exit(0);
}
//for(int i=0;fgetc(fp)!='\0';i++)
while(!feof(fp))
{
if(((fgetc(fp)>='a')&&(fgetc(fp)<='z'))||((fgetc(fp)>='A')&&(fgetc(fp)<='Z')))
putchar(fgetc(fp));
num++;
}
printf("%s numbers is %d",filename,num);
return 0;
}
1.rar
(410 Bytes)