#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("==");
    }

Recommended Answers

All 2 Replies

>>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)

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.