Réglages de problèmes

master
Yann CHAMPEAU 3 years ago
parent ad820cf62e
commit b7e9cc297a

@ -60,16 +60,13 @@ int loadIUT(VilleIUT** tiut){
} }
int rechercheIUT(VilleIUT* tab[],int lTab,char mot[]){ int rechercheIUT(VilleIUT* tab[],int lTab,char mot[]){
printf("CPT1\n");
/*
if(!lTab){ if(!lTab){
fprintf(stderr,"Erreur, Pas de villes enregistrées !\n"); fprintf(stderr,"Erreur, Pas de villes enregistrées !\n");
return -1; return -1;
} }
for(int i=0; i<lTab;i++){ for(int i=0; i<lTab;i++){
if(tab[i]->Ville==mot) return i; if(!strcmp(tab[i]->Ville,mot)) return i;
} }
*/
return -1; return -1;
} }

@ -12,8 +12,7 @@ void menuUser(VilleIUT* lvIUT[],int tlogi)
{ {
int quit=0; int quit=0;
while(!quit) while(!quit)
{ {
int intUserEntry=0;
printf("#--------------------------------------------------------------------#\n"); printf("#--------------------------------------------------------------------#\n");
printf("| |\n"); printf("| |\n");
printf("| SAE S1.02 |\n"); printf("| SAE S1.02 |\n");
@ -26,6 +25,7 @@ void menuUser(VilleIUT* lvIUT[],int tlogi)
printf("4 : Rechercher les IUTs possèdant un département précis.\n"); printf("4 : Rechercher les IUTs possèdant un département précis.\n");
printf("9 : Revenir à l'écran de sélection du profil.\n\n"); printf("9 : Revenir à l'écran de sélection du profil.\n\n");
printf("#--------------------------------------------------------------------#\n\n"); printf("#--------------------------------------------------------------------#\n\n");
printf("Choisissez l'action que vous voulez exécuter : ");
int act; int act;
scanf("%d",&act); scanf("%d",&act);
switch(act){ switch(act){
@ -47,7 +47,7 @@ void menuUser(VilleIUT* lvIUT[],int tlogi)
break; break;
case 9: case 9:
quit=1; quit=1;
break; reset();
} }
} }
@ -55,14 +55,14 @@ void menuUser(VilleIUT* lvIUT[],int tlogi)
void SearchCityWithIUT(VilleIUT* lvIUT[], int tlogi) void SearchCityWithIUT(VilleIUT* lvIUT[], int tlogi)
{ {
for (int i=0;i<tlogi;++i) printf("%s",lvIUT[i]->Ville); for (int i=0;i<tlogi;++i) printf("\n - %s",lvIUT[i]->Ville);
} }
void DepEachIUT(VilleIUT* lvIUT[], int tlogi) void DepEachIUT(VilleIUT* lvIUT[], int tlogi)
{ {
for (int i=0;i<tlogi;++i) for (int i=0;i<tlogi;++i)
{ {
printf("%s :",lvIUT[i]->Ville); printf("\n - %s :",lvIUT[i]->Ville);
MaillonDep* MaillonAct=lvIUT[i]->ldept; MaillonDep* MaillonAct=lvIUT[i]->ldept;
while (MaillonAct!=NULL) printf("\t-%s\n",MaillonAct->departement); while (MaillonAct!=NULL) printf("\t-%s\n",MaillonAct->departement);
} }
@ -209,30 +209,38 @@ void creerDep(VilleIUT* tiut[],int tlogi){
scanf("%*c%s",ville); scanf("%*c%s",ville);
if(ville[0]=='Q' && ville[1]=='\0') return; if(ville[0]=='Q' && ville[1]=='\0') return;
int noVille=rechercheIUT(tiut,tlogi,ville); int noVille=rechercheIUT(tiut,tlogi,ville);
if(noVille<=0){ if(noVille<0){
fprintf(stderr,"\nVille non existante !\n"); fprintf(stderr,"\nVille non existante !\n");
return; return;
} }
VilleIUT* v=tiut[noVille]; VilleIUT* v=tiut[noVille];
MaillonDep* m=v->ldept; int ck=0;
while(m->suivant!=NULL) m=m->suivant; if(v->ldept==NULL){
m->suivant=(MaillonDep*)malloc(sizeof(MaillonDep)); ck=1;
if(m->suivant==NULL){ v->ldept=(MaillonDep*)malloc(sizeof(MaillonDep));
perror("malloc"); if(v->ldept==NULL){
exit(errno); perror("malloc");
exit(errno);
}
} }
m=m->suivant; MaillonDep* m=v->ldept;
printf("\n\nEntrez le nom du département à créer :"); if(!ck){
char dep[31]; while(m->suivant!=NULL) m=m->suivant;
scanf("%*c%s",dep); m->suivant=(MaillonDep*)malloc(sizeof(MaillonDep));
strcpy(m->departement,dep); if(m->suivant==NULL){
printf("\n\nEntrez le nombre de places disponibles dans le département :"); perror("malloc");
exit(errno);
}
m=m->suivant;
}
printf("\n\nEntrez le nom du département à créer : ");
scanf("%*c%s",m->departement);
printf("\n\nEntrez le nombre de places disponibles dans le département : ");
scanf("%d",&m->nbp); scanf("%d",&m->nbp);
printf("\n\nEntrez le nom du responsable de département :"); printf("\n\nEntrez le nom du responsable de département : \n");
char resp[51]; scanf("%*c");
scanf("%*c%s",resp); fgets(m->resp, 51, stdin);
strcpy(m->resp,resp); printf("\n\nLe département %s a bien été ajouté à l'IUT de %s.\n",m->departement,ville);
printf("\n\nLe département %s a bien été ajouté à l'IUT de %s.\n",dep,ville);
return; return;
} }
@ -311,9 +319,7 @@ void creerIUT(VilleIUT* tiut[],int* tlogi){
char ville[31]; char ville[31];
scanf("%*c%s",ville); scanf("%*c%s",ville);
if(ville[0]=='Q' && ville[1]=='\0') return; if(ville[0]=='Q' && ville[1]=='\0') return;
fprintf(stderr,"before !\n");
int noVille=rechercheIUT(tiut,*tlogi,ville); int noVille=rechercheIUT(tiut,*tlogi,ville);
fprintf(stderr,"end !\n");
if(noVille>0){ if(noVille>0){
fprintf(stderr,"\nVille déjà existante !\n"); fprintf(stderr,"\nVille déjà existante !\n");
return; return;

@ -3,7 +3,7 @@
#include <errno.h> #include <errno.h>
#include "saeP2.h" #include "saeP2.h"
candidat* LoadCandid(void) /*candidat* LoadCandid(void)
{ {
//J'ouvre le fichier //J'ouvre le fichier
FILE* file; FILE* file;
@ -63,7 +63,7 @@ candidat* LoadCandid(void)
//Je sors en disant que le load est sucessful //Je sors en disant que le load est sucessful
printf("Chargement réussie."); printf("Chargement réussie.");
return Listecandidat; return Listecandidat;
} }*/
/* /*
void RechercheCandidat(int ID, int nbcandidat, int tmax,candidat *tcand) void RechercheCandidat(int ID, int nbcandidat, int tmax,candidat *tcand)
{ {

@ -1,5 +1,5 @@
typedef struct /*typedef struct
{ {
char ville[31]; char ville[31];
char dep[31]; char dep[31];
@ -18,4 +18,4 @@ typedef struct
candidat* LoadCandid(void); candidat* LoadCandid(void);
//void gestionPhaseCandidatures(); A FAIRE. //void gestionPhaseCandidatures(); A FAIRE.*/

@ -20,12 +20,10 @@ int main(void)
case 'C': case 'C':
reset(); reset();
menuUser(tiut,tlogi); menuUser(tiut,tlogi);
reset();
break; break;
case 'A': case 'A':
reset(); reset();
menuAdmin(tiut,&tlogi); menuAdmin(tiut,&tlogi);
reset();
break; break;
case 'Q': case 'Q':
printf("Êtes-vous sûr de vouloir quitter ? (Y pour continuer)\n\n"); printf("Êtes-vous sûr de vouloir quitter ? (Y pour continuer)\n\n");

Loading…
Cancel
Save