From 136377ff7fc55cbd0ecf0c36f03a0d410c60550a Mon Sep 17 00:00:00 2001 From: Guillaume Date: Fri, 13 Jan 2023 16:17:57 +0100 Subject: [PATCH] fonction creerCandidat finie normalment youpi --- source/sae.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/source/sae.c b/source/sae.c index b16774f..5911849 100644 --- a/source/sae.c +++ b/source/sae.c @@ -739,6 +739,12 @@ int creerCandidat(Candidat *tCand[], int nbCandidats) int i=0; Candidat *c; + c = (Candidat *) malloc (sizeof(Candidat)); + if(c==NULL) + { + printf("Probleme malloc\n"); + exit(1); + } c->numero = nbCandidats; printf("Le numero du candidat entrain d'etre cree est : %d\n", c->numero); printf("Nom du candidat (peut contenir des espaces): "); @@ -750,12 +756,16 @@ int creerCandidat(Candidat *tCand[], int nbCandidats) i=0; while(i<4) { - printf("Rentrez une note : "); + printf("Rentrez la note numero %d : ", i+1); scanf("%f", &c->notes[i]); + while(c->notes[i] < 0 || c->notes[i] > 20) + { + printf("Erreur, la note doit etre comprise entre 0 et 20.\nRessaisir la note numero %d : ", i+1); + scanf("%f", &c->notes[i]); + } i = i + 1; } c->lchoix = listenouvC(); - c = (Candidat *) malloc (sizeof(Candidat)); tCand[nbCandidats] = c; return nbCandidats + 1; }