diff --git a/header/sae.h b/header/sae.h index 8da1861..32b4604 100644 --- a/header/sae.h +++ b/header/sae.h @@ -152,6 +152,11 @@ bool vide(ListeDept ldept); int longueur(ListeDept ldept); void afficherListe(ListeDept ldept); +// Choix.c +lChoix ajouterEnteteC( lChoix lchoix, char ville[], char departement[], int decision, int validation); +lChoix supprimerEnTeteC( lChoix lchoix ); +lChoix listenouvC(); + // iut.c diff --git a/source/choix.c b/source/choix.c index e69de29..2ec0fd6 100644 --- a/source/choix.c +++ b/source/choix.c @@ -0,0 +1,67 @@ +#include "../header/sae.h" + + +/** + * @brief Ajoute un choix à la liste de choix + * @param lchoix juste de choix auquel un mayon est rajouté + * @param ville La ville du nouveau choix + * @param departement Le departement du nouveau choix + * @param decision La décision du département pour le choix + * @param validation La validation du candidat pour le choix + + * @return La liste avec le nouveau maillon + */ +lChoix ajouterEnteteC( lChoix lchoix, char ville[], char departement[], int decision, int validation) +{ + Choix * c = ( Choix * ) malloc ( sizeof ( Choix )); + if ( c == NULL ) + { + printf("\n --> Erreur d'allocation memoire \n"); + exit(1); + } + + strcpy( c -> ville, ville ); + strcpy( c -> departement, departement ); + c -> decisionDepartement = decision; + c -> validationCandidat = validation; + + c -> suiv = lchoix; + lchoix = c; + + return lchoix; +} + +/** + * @brief supprime un maillon de la liste + * @param lchoix juste de choix auquel un mayon est rajouté + * + * @return La liste avec le maillon en moins + */ +lChoix supprimerEnTeteC( lChoix lchoix ) +{ + Choix * aux; + if ( lchoix == NULL ) + { + printf(" \n --> operation impossible \n"); + exit(1); + } + + aux = lchoix; + lchoix = lchoix -> suiv; + free( aux ); + + return lchoix; +} +/** + * @brief Initialise une liste vide + * @return La liste vide + */ +lChoix listenouvC() +{ + lChoix l; + l = NULL; + return l; +} + + + diff --git a/source/test.c b/source/test.c index 0eb50d3..b7e94a9 100644 --- a/source/test.c +++ b/source/test.c @@ -43,7 +43,7 @@ void guillaume(void) Candidat tCandid[50]; int nbCandidats=2; - nbCandidats = creerCandid(tCandid, nbCandidats); + //nbCandidats = creerCandid(tCandid, nbCandidats); printf("\n%d", nbCandidats); }