比较两个文件内容
#include
#include
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);
}
若日志经rss订阅或导入到外站,可能有些视频和图片无法显示,请点击原文链接查看。
本文链接地址: http://imtimmy.com/%e6%af%94%e8%be%83%e4%b8%a4%e4%b8%aa%e6%96%87%e4%bb%b6%e5%86%85%e5%ae%b9/转载请注明: 转载自Timmy's Blog
如果你觉得本博内容不错,欢迎 [订阅 Timmy's Blog],以便第一时间了解本博更新内容;
不妨再看看这些相关的日志:
最新评论