regarde ici sur l'exemple avec fget http://www.siteduzero.com/tutoriel-3-14 ... #ss_part_2
#define TAILLE_MAX 1000 // Tableau de taille 1000
int main(int argc, char *argv[])
{
FILE* fichier = NULL;
char chaine[TAILLE_MAX] = ""; // Chaîne vide de taille TAILLE_MAX
fichier = fopen("test.txt", "r");
if (fichier != NULL)
{
fgets(chaine, TAILLE_MAX, fichier); // On lit maximum TAILLE_MAX caractères du fichier, on stocke le tout dans "chaine"
printf("%s", chaine); // On affiche la chaîne
fclose(fichier);
}
return 0;
}
--->
#define TAILLE_MAX 1000 // Tableau de taille 1000
int main(int argc, char *argv[])
{
FILE* fichier1 = NULL;
char chaine1[TAILLE_MAX] = ""; // Chaîne vide de taille TAILLE_MAX
fichier1 = fopen("test1.txt", "r");
FILE* fichier2 = NULL;
char chaine2[TAILLE_MAX] = ""; // Chaîne vide de taille TAILLE_MAX
fichier2 = fopen("test2.txt", "r");
if ((fichier1 != NULL) && (fichier2 != NULL))
{
fgets(chaine1, TAILLE_MAX, fichier1); // On lit maximum TAILLE_MAX caractères du fichier, on stocke le tout dans "chaine"
printf("ligne fichier 1 %s", chaine1); // On affiche la chaîne
fgets(chaine2, TAILLE_MAX, fichier2); // On lit maximum TAILLE_MAX caractères du fichier, on stocke le tout dans "chaine"
printf("ligne fichier 2 %s", chaine2); // On affiche la chaîne
if (chaine1 != chaine2)
{
printf("fichiers differents");
}
}
fclose(fichier1);
fclose(fichier2);
return 0;
}