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;
- int q1,q2;
- char str[200];
- printf("Enter first path: ");
- gets(str);
- fp1 = fopen(str , "rb");
- printf("Enter second path: ");
- gets(str);
- fp2 = fopen(str , "rb");
- if(fp1 == NULL || fp1 == NULL) {
- printf("Can't open file\n");
- exit(0);
- }
- do{
- if (feof(fp1)){
- if (!feof(fp2)) sss=fail;
- break;
- }
- if (sss==fail) break;
- fread(&q1, sizeof(int) ,1,fp1);
- fread(&q2, sizeof(int) ,1,fp2);
- if (q1 != q2){
- printf("Different value\n");
- sss=fail;
- }
- }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