From b4801bc7fbca4d6e87ab0bdc84c3b06c07cd3fce Mon Sep 17 00:00:00 2001 From: Nicolas BLONDEAU Date: Thu, 5 Jan 2023 17:36:22 +0100 Subject: [PATCH] =?UTF-8?q?M=C3=A0j=20mais=20fonction=20de=20recherche=20d?= =?UTF-8?q?e=20places=20qui=20fonctionne=20pas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- iut.h | 1 + utilisateurIut.c | 44 ++++++++++++++++++++++++++++++-------------- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/iut.h b/iut.h index 10759f2..3ee6120 100644 --- a/iut.h +++ b/iut.h @@ -21,6 +21,7 @@ typedef enum {faux,vrai}Booleen; void MenuUtilisateur(VilleIUT *tiut[],int n); int rechercheIUT(VilleIUT *tiut[],int n); int rechercheDept(VilleIUT *tiut[], int n); + int recherchePlaces(VilleIUT *tiut[], int n); //Menu administrateur : void MenuAdministrateur(VilleIUT *tiut[],int n); diff --git a/utilisateurIut.c b/utilisateurIut.c index b23a1bd..ce0bc24 100644 --- a/utilisateurIut.c +++ b/utilisateurIut.c @@ -14,17 +14,9 @@ void MenuUtilisateur(VilleIUT *tiut[], int n){ } if(choix==2){ succes = rechercheDept(tiut, n); - //creer departemement - /*printf("\ndepartement :"); - scanf("%s",departement); - printf("\nnombre de place :"); - scanf("%d",&nbp); - printf("\nresponsable :"); - scanf("%s",respon);*/ - //V=Enfiler(V,departement,nbp,respon); } if(choix==3){ - // + succes = recherchePlaces(tiut, n); } if(choix==4){ // @@ -43,17 +35,17 @@ int rechercheIUT(VilleIUT *tiut[], int n){ char rech[31]; int i, trouve = 0; printf("\nEntrez le nom d'une ville ou d'un IUT : "); - scanf("%s", &rech); + scanf("%s%*c", &rech); for(i=0;iville, rech)==0){ printf("\nIl y a un IUT à %s.\n", rech); trouve = 1; - return 1; + return 0; } else if(i==n-1) printf("\nIl n'y pas d'IUT dans votre ville.\n"); } - return 0; + return 1; } int rechercheDept(VilleIUT *tiut[], int n){ @@ -61,7 +53,7 @@ int rechercheDept(VilleIUT *tiut[], int n){ int i, trouve = 0, j = 0; ListeD ld = tiut[i]->ldept; printf("\nEntrez le nom d'une ville ou d'un IUT : "); - scanf("%s", &rech); + scanf("%s%*c", &rech); for(i=0;iville, rech)==0){ printf("\nListe des départements :\n\n"); @@ -69,11 +61,35 @@ int rechercheDept(VilleIUT *tiut[], int n){ printf("%s\t",ld->departement); printf("Responsable : %s\n",ld->resp); ld = ld->suivant; + return 0; } trouve = 1; } else if(i==n-1) printf("\nAucun département trouvé, il n'y pas d'IUT dans votre ville.\n"); } - return 0; + return 1; +} + +//FONCTIONNE PAS ENCORE, ERREUR DE SEGMENTATION : +int recherchePlaces(VilleIUT *tiut[], int n){ + int err; + char rech[31]; + int i, trouve = 0; + printf("OK"); + //err = rechercheDept(tiut, n); ERREUR ICI + printf("OK"); + printf("Quel département ? "); + printf("OK"); + scanf("%s", &rech); + for(i=0;ildept->departement, rech)==0){ + printf("\nNombre de places disponibles : %d\n\n", tiut[i]->ldept->nbP); + trouve = 1; + return 0; + } + else if(i==n-1) + printf("\nAucun département trouvé, il n'y pas d'IUT dans votre ville.\n"); + } + return 1; }