#include <stdio.h> #include <stdlib.h> #include <string.h>
main() { CmpFiles(); return 0; }
CmpFiles() { FILE * fp1; FILE * fp2; char c1[100], c2[100]; int cmp; fp1 = fopen("Doc1.txt", "r"); fp2 = fopen("Doc2.txt", "r"); if((fp1 == NULL) || (fp2 == NULL)) { printf("Error in the file n"); } else { while(fgets(c1 , 15, fp1) != NULL) //reads from the file puts(c1); //sends output to stdout while(fgets(c2 , 15, fp2) != NULL) puts(c2); if((cmp = strcmp(c1, c2)) == 0) { printf("Files are same n"); } else { printf("Files are differnt n"); } } } |