Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- enum status {success, fail};
- void main() {
- enum status sss=success;
- FILE *fp1,*fp2;
- char q1,q2,i=1;
- fp1 = fopen("rrr.txt" , "r");
- fp2 = fopen("ttt.txt" , "r");
- if(fp1 == NULL || fp1 == NULL) {
- printf("Can't open file\n");
- exit(0);
- }
- do{
- if (feof(fp1) != !feof(fp2) ){ // כנראה כאן הבעיה
- sss=fail;
- printf("Length is not the same\n");
- printf("I = %d\n",i);
- break;
- }
- if (feof(fp1)){
- printf("Length is the same\n");
- if (feof(fp2)) printf("F2 ends too\n");
- break;
- }
- q1 = fgetc(fp1);
- q2 = fgetc(fp2);
- if (q1 != q2){
- printf("Different value\n");
- sss=fail;
- break;
- }
- i=0;
- } while(1);
- (sss==success)? printf("The files are the same!\n"): printf("The files are NOT the same!\n");
- fclose(fp1);
- fclose(fp2);
- }
Advertisement
Add Comment
Please, Sign In to add comment