From 5537943d704d15ec2bbdf078a5d75b2b4699a739 Mon Sep 17 00:00:00 2001 From: Guillaume Date: Fri, 13 Jan 2023 16:32:15 +0100 Subject: [PATCH] fonction creerCandidat + affichage qui marche youpi --- header/sae.h | 8 +------- source/sae.c | 4 +++- source/test.c | 3 ++- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/header/sae.h b/header/sae.h index 620b2c1..55fc3e6 100644 --- a/header/sae.h +++ b/header/sae.h @@ -131,15 +131,9 @@ void afficheNbPlacesDep(VilleIut *tiut[], int nbVilles, char nomDept[]); int existeVille( VilleIut *tiut[], char ville[], int nbvilles ); void menuAdmin(VilleIut *tiut[], int nbVilles); -<<<<<<< HEAD -void afficherCandidat(Candidat candidat); -void afficherCandidats(Candidat *candidats, int nbCandidats); -int creerCandidat(Candidat *tCand[], int nbCandidats); -======= void afficherUnCandidat(Candidat candidat); void afficherCandidats(Candidat **candidats, int nbCandidats); -int creerCandid(Candidat tCand[], int nbCandidats); ->>>>>>> bcdeb24491974b30c7e1ad6913f0e3fa2c3be9c3 +int creerCandidat(Candidat *tCand[], int nbCandidats); ListeDeptV2 configurationDeptV2( ListeDept ldept ); diff --git a/source/sae.c b/source/sae.c index af34e03..00e22b6 100644 --- a/source/sae.c +++ b/source/sae.c @@ -732,8 +732,10 @@ void menuAdmin(VilleIut **villeIut, int nbVilles) void afficherCandidats(Candidat **candidats, int nbCandidats) { for (int i = 0; i < nbCandidats; i++) + { printf("\nCandidat numero %8d | Nom : %10s | Prenom : %10s \n", candidats[i] -> numero, candidats[i] -> nom, candidats[i] -> prenom); + } } @@ -748,7 +750,7 @@ int creerCandidat(Candidat *tCand[], int nbCandidats) printf("Probleme malloc\n"); exit(1); } - c->numero = nbCandidats; + c->numero = nbCandidats+1; printf("Le numero du candidat entrain d'etre cree est : %d\n", c->numero); printf("Nom du candidat (peut contenir des espaces): "); fgets(c->nom, 50, stdin); diff --git a/source/test.c b/source/test.c index ece531e..155aeb9 100644 --- a/source/test.c +++ b/source/test.c @@ -41,10 +41,11 @@ void guillaume(void) { Candidat *tCandid[50]; - int nbCandidats=2; + int nbCandidats=0; nbCandidats = creerCandidat(tCandid, nbCandidats); printf("\n%d\n", nbCandidats); + afficherCandidats(tCandid, nbCandidats); }