C语言文件比较

来源:百度知道 编辑:UC知道 时间:2024/05/16 17:59:29
有两个文件 1.txt ,2.txt ,用标准C语言代码 写段程序比较两个文件内容是否相等。

check the two files

#include <stdio.h>
#include <string.h>
main()
{FILE *fp1,*fp2;
if((fp1=fopen("1.txt","r"))==NULL)
{printf("Can't open the file1.\n"); exit(0); }
if((fp2=fopen("2.txt","r"))==NULL)
{printf("Can't open the file2.\n"); exit(0); }
if(strcmp(fp1,fp2)==0)
printf("the two file is same!!!\n");
else printf("the two file isn't same!!!\n");
}
有点问题
等我考试完了后来帮你做,表着急哦
呵呵