直接上代码:
#include<stdio.h> #include <windows.h> int main() { FILE *f1,*f2; char ch1,ch2; char fileName1[100],fileName2[100]; printf("Enter first filename :\n"); scanf("%s",fileName1); printf("Enter second filename :\n"); scanf("%s",fileName2); if(((f1=fopen(fileName1,"r"))==0) || ((f2=fopen(fileName2,"r"))==0)) { printf("Files do not exist!!\n"); return 0; } do { ch1=fgetc(f1); ch2=fgetc(f2); if(ch1!=ch2) { printf("different!\n") ; return 0; } }while(ch1!=EOF || ch2!=EOF); printf("same!\n"); system("pause"); return 0; }
时间: 2024-10-28 12:59:38