From ab12d872d097f6c3ef70b5e400fa6d8f32c5409e Mon Sep 17 00:00:00 2001 From: Roxane Rossetto Date: Fri, 13 Jan 2023 11:41:19 +0100 Subject: [PATCH] fct chargement, test --- part4.c | 44 +++++++++++++++++++++++++++++++++++++++++++- part4.h | 1 + 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/part4.c b/part4.c index bd6a176..c68941a 100644 --- a/part4.c +++ b/part4.c @@ -273,10 +273,37 @@ Filecand ChargementfileC(Filecand fC, int *nbC)//chargement du fichier dans cett return fC; } - +int chargement (Candidat tCandAcc[], int tmax, FILEfe){// chargement des files cand et chx + + + fscanf( fe, "%d", nbCand ); + + c = lireCa (fe); + + while ( !feof(fe) ){ + if ( i == tmax){ + printf("La liste des candidats admis est complète\n"); + return 0; + } + tCandAcc[i] = (Candidat *) malloc (sizeof(Candidat)); + if (tCandAcc[i] == NULL ){ + printf("Problème malloc\n"); + return -1; + } + *tCandAcc[i] = c; + fscanf( fe, "%d", &nbC); + tCandAcc[i]->lchx = Chargementlistecandidat ( fe, tCandAcc[i]->lchx, nbC); + i++; + c = lireCa (fe); + } + fclose (fe); + return i; +} void test (void){ FILE *fe; + int menu1, tlog; + CandidattCand[120]; fe = fopen( "part4.don", "r"); if ( fe == NULL ){ @@ -288,5 +315,20 @@ void test (void){ fC = initcand(); fC = ChargementfileC(fC, &nbC); + tlog = chargement (tCand, 120, fe); + Afftab(tCand, tlog); + + /* + printf("Etes-vous un candidat(1) ou un responsable(2)?\n"); + scanf("%d", &menu1); + + while( menu1 == 1 || menu1 == 2 ){ + + if ( menu1 == 1 ){ + + } + } + */ } + diff --git a/part4.h b/part4.h index ee09b17..3999697 100644 --- a/part4.h +++ b/part4.h @@ -52,6 +52,7 @@ Filecand enfC(Filecand fC, Candidat c); Filechx enf(Filechx fchx, Choix c); Choix def(Filechx fc); Candidat defC(Filecand fC); +int chargement (Candidat tCandAcc[], int tmax, FILEfe);// chargement des files cand et chx void test (void);