Correction du bug menu candidat qui causait une erreur de segmentation

master
Johnny RATTON 2 years ago
parent a7297befe6
commit 36d5c7b4fb

@ -1,4 +1,4 @@
#include "M2sae.h" #include "Msae.h"
/*********************************************************** Fonctions de listes **************************************************************/ /*********************************************************** Fonctions de listes **************************************************************/
/**********************************************************************************************************************************************/ /**********************************************************************************************************************************************/
@ -168,7 +168,7 @@ void afficherVilleDep(VilleIUT v) /* Permet d'afficher une ville passée en para
l = v.lDept; l = v.lDept;
while(l != NULL) 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"); printf("|----------------------------------|----------------------------------------------------------------------------|\n");
l = l->suiv; l = l->suiv;
} }
@ -194,7 +194,7 @@ void afficheDeptDesIUT(VilleIUT *tiut[], int tLog)
rechercherDept(tiut[i]->lDept,dept,&trouve); rechercherDept(tiut[i]->lDept,dept,&trouve);
if (trouve==1) if (trouve==1)
{ {
printf("|%s",tiut[i]->nom); printf("* %s\n",tiut[i]->nom);
} }
} }
printf("|\n"); printf("|\n");
@ -592,7 +592,7 @@ int login(Candidat *tCand[],int *tMax,int *pos) /* Affiche un menu de connexion
int i = 3,trouve,numC; int i = 3,trouve,numC;
char id, mdp[31] = "mettez20svp", mdpatrouve[31],choix; /* Déclaration d'un motdepasse administrateur */ char id, mdp[31] = "mettez20svp", mdpatrouve[31],choix; /* Déclaration d'un motdepasse administrateur */
system("clear"); 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); scanf("%c%*c",&id);
if(id == 'q') /* Si l'utilisateur saisie la lettre 'q', le programme s'arrête */ 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 */ while(id != 'A' && id != 'a' && id != 'C' && id != 'c') /* Effectue une saisie contrôlée si la saisie ne correspond à aucune option */
{ {
system("clear"); 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); scanf("%c%*c",&id);
if(id == 'q') if(id == 'q')
{ {
@ -851,7 +851,7 @@ void menuCandidat(VilleIUT *tiut[], int *tLog, int tMax,Candidat *tCand[],int tM
} }
if(select==3) if(select==3)
{ {
printf("Quel IUT ?\nSaisie :"); printf("Quel IUT ?\nSaisie : ");
scanf("%s%*c",ville); scanf("%s%*c",ville);
pos=rechercheIUT(tiut,*tLog,ville,&trouve); pos=rechercheIUT(tiut,*tLog,ville,&trouve);
while(trouve==0) while(trouve==0)
@ -881,26 +881,26 @@ void menuCandidat(VilleIUT *tiut[], int *tLog, int tMax,Candidat *tCand[],int tM
{ {
if(select == 5) 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) if(select == 6)
{ {
tCand[pos]->tChoix = insererChoix(tCand[pos]->tChoix, &tCand[pos]->nombreChoix); tCand[posC]->tChoix = insererChoix(tCand[posC]->tChoix, &tCand[posC]->nombreChoix);
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]);
} }
clearpage(); clearpage();
} }
if(select == 7) if(select == 7)
{ {
tCand[pos]->tChoix = supprimerChoix(tCand[pos]->tChoix, &tCand[pos]->nombreChoix); tCand[posC]->tChoix = supprimerChoix(tCand[posC]->tChoix, &tCand[posC]->nombreChoix);
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]);
} }
clearpage(); clearpage();
} }
@ -916,7 +916,7 @@ void menuCandidat(VilleIUT *tiut[], int *tLog, int tMax,Candidat *tCand[],int tM
} }
else else
{ {
retour=miseAJourChoixCand(tCand[pos]->tChoix, tCand[pos]->nombreChoix); retour=miseAJourChoixCand(tCand[posC]->tChoix, tCand[posC]->nombreChoix);
if (retour==-2 || retour==0) if (retour==-2 || retour==0)
{ {
printf("Vos choix n'ont pas été mis à jour.\n"); 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) if (retour==1)
{ {
while(j<tCand[pos]->nombreChoix) while(j<tCand[posC]->nombreChoix)
{ {
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++; j++;
} }
@ -937,16 +937,16 @@ void menuCandidat(VilleIUT *tiut[], int *tLog, int tMax,Candidat *tCand[],int tM
} }
if(retour==-1) if(retour==-1)
{ {
while (j<tCand[pos]->nombreChoix) while (j<tCand[posC]->nombreChoix)
{ {
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; break;
} }
} }
suppr=rechercherCandListe(*ladmis,tCand[pos]->numeroC,&trouve); suppr=rechercherCandListe(*ladmis,tCand[posC]->numeroC,&trouve);
*ladmis=supprimerCand(*ladmis,tCand[pos]); *ladmis=supprimerCand(*ladmis,tCand[posC]);
*f=fileToAdmis(*f,ladmis,1,mini); *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 */ 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 */ 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) if(retour == 1)
{ {
menuAdmin(tiut, &tLog, 100,tCand,tMax,&phaseCandidature,&f,&ladmis); menuAdmin(tiut, &tLog, 100,tCand,tMax,&phaseCandidature,&f,&ladmis);

Loading…
Cancel
Save