Hello
je vous expose mon probleme, j'ecrit dans un fichier une structure qui comporte "Adherent.nom" et dans un autre fichier une structure comportant "RDV.nom"
et je souhaite comparer les 2 et lorsqu'elles sont egale, afficher la structure RDV.
mais voila, cela marche uniquement lorsque les noms egaux sont à la meme position dans leurs fichiers respectif.
Par exemple si adherent.nom = billy et est enregistrer en 2nd position dans le fichier, mais que RDV.nom = billy est en 3ieme position, le programme ne trouvera rien ...

voici le code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
#define NOM 30
#define PRENOM 30
#define DATE_NAISSANCE 10
#define NIVEAU 30
#define CONTACT 11
 
typedef struct
{
	char Nom[NOM];
	char Prenom[PRENOM];
	char DateNaissance[DATE_NAISSANCE];
	double Poids;
	double Taille;
	char Niveau[NIVEAU];
	char Contact[CONTACT];
} Adherent;
typedef struct
{
	double Date;
	double Heure;
	char NomAdherent[NOM];
} RDV;
void adherentRDV(void) \\ gros soussie, si les enregistrement ne sont pas à la meme position dans le fichier, ca ne fonctionne pas
{
FILE* fichierRDV = NULL;
FILE* fichierAdherent = NULL;
	RDV RDV;
	Adherent Adherent;
	int retourRDV = 0, retourAdherent = 0;
	int trouve = 0;
	/*Effacer ecran*/
	system("CLS");
 
	/*Titre*/
	printf("--- Liste RDV Adherents---\n\n");
 
	/*Recuperation des données*/
	fichierRDV=fopen("FichierRDV.txt","r");
	fichierAdherent=fopen("FichierAdherent.txt","r");
 
	if (fichierRDV != NULL && fichierAdherent != NULL)
	{
		retourRDV = fscanf(fichierRDV,"%lf\n%lf\n%s\n\n", &RDV.Date,&RDV.Heure,RDV.NomAdherent);
		retourAdherent = fscanf(fichierAdherent, "%s\n%s\n%s\n%lf\n%lf\n%s\n%s\n\n",
		Adherent.Nom, Adherent.Prenom, Adherent.DateNaissance, &Adherent.Poids, &Adherent.Taille, Adherent.Niveau, Adherent.Contact);
		while(retourRDV != EOF && retourAdherent != EOF)
		{
			if (strcmp(Adherent.Nom, RDV.NomAdherent) == 0) 
					{
						printf("Adherent : %s a RDV a %.0f H le %.0f\n\n", RDV.NomAdherent, RDV.Heure, RDV.Date);
					}
		trouve =1;
		retourRDV = fscanf(fichierRDV,"%lf\n%lf\n%s\n\n", &RDV.Date,&RDV.Heure,RDV.NomAdherent);
		retourAdherent = fscanf(fichierAdherent, "%s\n%s\n%s\n%lf\n%lf\n%s\n%s\n\n",
		Adherent.Nom, Adherent.Prenom, Adherent.DateNaissance, &Adherent.Poids, &Adherent.Taille, Adherent.Niveau, Adherent.Contact);
 
		}
		if(trouve!=1)
		{
			printf("Aucun Adherent n'a de RDV");
		}
		fclose(fichierRDV);
		fclose(fichierAdherent);
	}
	else
	{
		printf("Impossible d'ouvrir le fichier");
		getchar();
	}
 
	system("PAUSE");
}
Si vous avez des idées, n'hesitez pas
Merci