From 36d5c7b4fb162f74ccb0ad2023c589a9a67de3c3 Mon Sep 17 00:00:00 2001 From: johnny Date: Fri, 13 Jan 2023 17:42:20 +0100 Subject: [PATCH] Correction du bug menu candidat qui causait une erreur de segmentation --- Msae.c | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/Msae.c b/Msae.c index 8d78e2f..e717e4c 100644 --- a/Msae.c +++ b/Msae.c @@ -1,4 +1,4 @@ -#include "M2sae.h" +#include "Msae.h" /*********************************************************** Fonctions de listes **************************************************************/ /**********************************************************************************************************************************************/ @@ -168,7 +168,7 @@ void afficherVilleDep(VilleIUT v) /* Permet d'afficher une ville passée en para l = v.lDept; while(l != NULL) { - printf("| %-32s | %-32s | %3d | %-32s |\n", v.nom, l->d.dept, l->d.nbP, l->d.respAd); + printf("| %-32s| %-32s| %3d |%-32s|\n", v.nom, l->d.dept, l->d.nbP, l->d.respAd); printf("|----------------------------------|----------------------------------------------------------------------------|\n"); l = l->suiv; } @@ -194,7 +194,7 @@ void afficheDeptDesIUT(VilleIUT *tiut[], int tLog) rechercherDept(tiut[i]->lDept,dept,&trouve); if (trouve==1) { - printf("|%s",tiut[i]->nom); + printf("* %s\n",tiut[i]->nom); } } printf("|\n"); @@ -592,7 +592,7 @@ int login(Candidat *tCand[],int *tMax,int *pos) /* Affiche un menu de connexion int i = 3,trouve,numC; char id, mdp[31] = "mettez20svp", mdpatrouve[31],choix; /* Déclaration d'un motdepasse administrateur */ system("clear"); - printf("\t################################ Bienvenue! ################################\nSouhaitez-vous vous connecter en tant qu'utilisateur ou administeur ? (C/A)\nSaisie : "); + printf("\t################################ Bienvenue! ################################\nSouhaitez-vous vous connecter en tant que candidat, administeur ou responsable d'admissions ? (C/A/R)\nSaisie : "); scanf("%c%*c",&id); if(id == 'q') /* Si l'utilisateur saisie la lettre 'q', le programme s'arrête */ { @@ -601,7 +601,7 @@ int login(Candidat *tCand[],int *tMax,int *pos) /* Affiche un menu de connexion while(id != 'A' && id != 'a' && id != 'C' && id != 'c') /* Effectue une saisie contrôlée si la saisie ne correspond à aucune option */ { system("clear"); - printf("\t#################### Mauvaise saisie ('q' pour quitter) ####################\nSouhaitez-vous vous connecter en tant qu'utilisateur ou administeur ou en tant que responsable? (C/A/R)\nSaisie : "); + printf("\t#################### Mauvaise saisie ('q' pour quitter) ####################\nSouhaitez-vous vous connecter en tant que candidat, administrateur ou responsable d'admissions ? (C/A/R)\nSaisie : "); scanf("%c%*c",&id); if(id == 'q') { @@ -851,7 +851,7 @@ void menuCandidat(VilleIUT *tiut[], int *tLog, int tMax,Candidat *tCand[],int tM } if(select==3) { - printf("Quel IUT ?\nSaisie :"); + printf("Quel IUT ?\nSaisie : "); scanf("%s%*c",ville); pos=rechercheIUT(tiut,*tLog,ville,&trouve); while(trouve==0) @@ -881,26 +881,26 @@ void menuCandidat(VilleIUT *tiut[], int *tLog, int tMax,Candidat *tCand[],int tM { if(select == 5) { - for(i = 0; i < tCand[pos]->nombreChoix; i++) + for(i = 0; i < tCand[posC]->nombreChoix; i++) { - afficherChoix(tCand[pos]->tChoix[i]); + afficherChoix(tCand[posC]->tChoix[i]); } } if(select == 6) { - tCand[pos]->tChoix = insererChoix(tCand[pos]->tChoix, &tCand[pos]->nombreChoix); - for(i = 0; i < tCand[pos]->nombreChoix; i++) + tCand[posC]->tChoix = insererChoix(tCand[posC]->tChoix, &tCand[posC]->nombreChoix); + for(i = 0; i < tCand[posC]->nombreChoix; i++) { - afficherChoix(tCand[pos]->tChoix[i]); + afficherChoix(tCand[posC]->tChoix[i]); } clearpage(); } if(select == 7) { - tCand[pos]->tChoix = supprimerChoix(tCand[pos]->tChoix, &tCand[pos]->nombreChoix); - for(i = 0; i < tCand[pos]->nombreChoix; i++) + tCand[posC]->tChoix = supprimerChoix(tCand[posC]->tChoix, &tCand[posC]->nombreChoix); + for(i = 0; i < tCand[posC]->nombreChoix; i++) { - afficherChoix(tCand[pos]->tChoix[i]); + afficherChoix(tCand[posC]->tChoix[i]); } clearpage(); } @@ -916,7 +916,7 @@ void menuCandidat(VilleIUT *tiut[], int *tLog, int tMax,Candidat *tCand[],int tM } else { - retour=miseAJourChoixCand(tCand[pos]->tChoix, tCand[pos]->nombreChoix); + retour=miseAJourChoixCand(tCand[posC]->tChoix, tCand[posC]->nombreChoix); if (retour==-2 || retour==0) { printf("Vos choix n'ont pas été mis à jour.\n"); @@ -924,11 +924,11 @@ void menuCandidat(VilleIUT *tiut[], int *tLog, int tMax,Candidat *tCand[],int tM } if (retour==1) { - while(jnombreChoix) + while(jnombreChoix) { - if (tCand[pos]->tChoix[j]->decisionCand!=1) + if (tCand[posC]->tChoix[j]->decisionCand!=1) { - tCand[pos]->tChoix[j]->decisionCand=-1; + tCand[posC]->tChoix[j]->decisionCand=-1; j++; } @@ -937,16 +937,16 @@ void menuCandidat(VilleIUT *tiut[], int *tLog, int tMax,Candidat *tCand[],int tM } if(retour==-1) { - while (jnombreChoix) + while (jnombreChoix) { - if(strcmp(tCand[pos]->tChoix[j]->ville, "Clermont-Ferrand") == 0 && strcmp(tCand[pos]->tChoix[j]->dep, "Informatique") == 0) + if(strcmp(tCand[posC]->tChoix[j]->ville, "Clermont-Ferrand") == 0 && strcmp(tCand[posC]->tChoix[j]->dep, "Informatique") == 0) { - tCand[pos]->tChoix[j]->decisionCand=-1; + tCand[posC]->tChoix[j]->decisionCand=-1; break; } } - suppr=rechercherCandListe(*ladmis,tCand[pos]->numeroC,&trouve); - *ladmis=supprimerCand(*ladmis,tCand[pos]); + suppr=rechercherCandListe(*ladmis,tCand[posC]->numeroC,&trouve); + *ladmis=supprimerCand(*ladmis,tCand[posC]); *f=fileToAdmis(*f,ladmis,1,mini); } } @@ -1144,6 +1144,7 @@ void globale(void) /* Permet l'initialisation du tableau, le chargement de celui retour = login(tCand,&tMax,&pos); /* Appelle la fonction login */ while(retour != -1) /* Tant que login ne retourne pas -1, la fonction appelle le menu adaptée en fonction du retour de login puis appelle de nouveau login */ { + afficherCandChoix(tCand, tMax); if(retour == 1) { menuAdmin(tiut, &tLog, 100,tCand,tMax,&phaseCandidature,&f,&ladmis);