Developpement/23DEV1.1/TPS1/TP2/controle/Reproduction.c

35 lines
880 B
C
Raw Normal View History

2024-12-09 11:53:11 +01:00
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char const *argv[])
{
FILE* fi1 = fopen(argv[1],"r");
FILE* fi2 = fopen(argv[2],"r");
char space1[91];
char space2[91];
int diff = 0;
if(argc<3){
fprintf(stderr,"erreur ! Le format doit etre sous forme : %s <fichier1> <fichier2>\n", argv[0]);
return EXIT_FAILURE;
}
if(fi1 == NULL || fi2 == NULL){
fprintf(stderr,"un des dossiers est indisponible !\n");
return EXIT_FAILURE;
}
while(!feof(fi1)&&!feof(fi2)){
fread(space1,1,1,fi1);
fread(space2,1,1,fi2);
if(space1[91] == space2[91]){
diff++;
}
}
printf("%d\n", diff);
if(diff>0){
printf("Fichiers identiques\n");
}else{
printf("Fichiers non identiques\n");
}
fclose(fi1);
fclose(fi2);
return EXIT_SUCCESS;
}