#include <stdio.h>
#include <stdlib.h>
void main()
{
FILE *f1,*f2;
int l,c;
char ch1,ch2;
if((f1=fopen("f1.txt","r"))==NULL){
printf("File open error\n");
exit(0);
}
if((f2=fopen("f2.txt","r"))==NULL){
printf("File open error\n");
exit(0);
}
l=c=1;
while(!feof(f1)&&!feof(f2)){
ch1=fgetc(f1);
ch2=fgetc(f2);
if(ch1!=ch2)
break;
else
c++;
if(ch1=='\n'){
c=1;
l++;
}
}
if(fclose(f1)){
printf("can't close file\n");
exit(0);
}
if(fclose(f2)){
printf("can't close file\n");
exit(0);
}
printf("l=%d,c=%d\n",l,c);
}
Add a comment



统计文件中字符
期末考试信息







