0
#include<iostream.h>   
 #include<stdio.h>
    #include<string.h>
    void remplir(FILE *f)
    {
    char c;
    char fichier[20];
    printf("entrer les nom du fichier:");
    scanf("%s",fichier);
    f=fopen(fichier,"w");
    if(f==NULL)
    printf("erreur");
    else
    while((c=getchar())!='.')
    {
    //putc(c,f);
    fprintf(f,"%c",c);
    }
}
    int comparer(FILE *f,FILE *fp)
    {
    char l1[10],l2[10];
    printf("OOO");
    while((!feof(f)) && (!feof(fp)))
    {
    fgets(l1,2,f);
    fgets(l2,2,fp);
    printf("OOO");
    if(strcmp(l1,l2))
    {
    printf("%s",l1);
    printf("%s",l2);
    return 0;
    }
    }
    if(!feof(f))
    {fgets(l1,10,f);
    printf("%s",l1);
    return 0;
    }
    if(!feof(fp))
    {fgets(l2,10,fp);
    printf("%s",l2);
    return 0;
    }
    return 1;
    }
    void main()
    {int i;
    FILE *f1,*fp1;
     
    remplir(f1);
     
     
    remplir(fp1);
     
    i=comparer(f1,fp1);
    if(i==0)printf("!=");
    else printf("==");
    }
3
Contributors
2
Replies
4
Views
6 Years
Discussion Span
Last Post by abhimanipal
1

>>Compare 2 files helppppppp

That does not tell us much about what problem you are facing. Help can be provided only when you tell us what the problem is.


PS:

#include<iostream.h> -> #include <iostream> (why iostream anyway?)
LINK

What compiler are you using?

Also, void main() -> int main(void)

Edited by myk45: n/a

0

What is the exact issue that you are facing ?

Other things that may help you
1. Dont use feof . Read this to know why .
2. Next time please use indentation when you write code / paste code. Its easier for us to read your code

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.