/* consider both the files have 15 characters*/ #include<stdio.h> #include<stdlib.h> #include<string.h> int cmpfiles(void); void main() { int result =cmpfiles(); printf("tn %d",result); }
int cmpfiles(void) { FILE *fp1.*fp2; fp1 = fopen(file1,'r'); // open the file1 to read its content fp2 = fopen(file1,'r'); // open the file2 to read its content
char c1[15],c2[15]; //declaring a string to hold the content of each file
fgets(c1,16,fp1); //reading the content of file1 into c1 fgets(c2,16,fp2);//reading the content of file2 into c2
if(strcmp(c1,c2) = = 0) { return 1; }
else return 0; } |