From 38f86f09147e603af0637cd70438377b3673177f Mon Sep 17 00:00:00 2001 From: Sami GHEBRID Date: Thu, 15 Dec 2022 11:58:22 +0100 Subject: [PATCH] Test rechercheIUT (fonctionnelle --- Ssae.c | 49 ++----------------------------------------------- Ssae.h | 2 +- Stest.c | 17 ++++++++++++++++- 3 files changed, 19 insertions(+), 49 deletions(-) diff --git a/Ssae.c b/Ssae.c index 398d024..03c168b 100644 --- a/Ssae.c +++ b/Ssae.c @@ -37,54 +37,9 @@ void clearpage(void) system("clear"); } -int chargement(VilleIUT *tiut[],int *tMax) -{ - FILE *flot; - VilleIUT *v; - MaillonDept *m; - int nb = 0, pos; - char trouve; - flot = fopen("IUT.don", "r"); - if(flot == NULL) - { - printf("Problème d'ouverture du fichier\n"); - return -1; - } - while(!feof(flot)) - { - v = (VilleIUT *)malloc(sizeof(VilleIUT)); - if(v == NULL) - { - printf("Problème allocation ville lors de la lecture du fichier\n"); - return -2; - } - fscanf(flot, "%s", v->nom); - pos = recherche(tiut, nb, v->nom, &trouve); - m = (MaillonDept *)malloc(sizeof(MaillonDept)); - if(m == NULL) - { - printf("Problème allocation département lors de la lecture du fichier\n"); - return -3; - } - *m = lireDep(flot); - if(trouve == 'O') - { - insererDep(tiut[pos],*m); - } - else - { - m->suiv = NULL; - v->lDept = m; - tiut[nb] = v; - } - free(v); - free(m); - nb++; - } - return nb; -} -int rechercheIUT(VilleIUT *tiut[], int tLog, char ville[], char *trouve){ + +int rechercheIUT(VilleIUT *tiut[], int tLog, char ville[], int *trouve){ int inf,sup,t; inf=0; sup=tLog-1; diff --git a/Ssae.h b/Ssae.h index 7a6c5db..883434d 100644 --- a/Ssae.h +++ b/Ssae.h @@ -24,7 +24,7 @@ typedef struct //################ Fonctions communes ################# void clearpage(void); -int rechercheIUT(VilleIUT *tiut[], int tLog, char ville[], char *trouve); +int rechercheIUT(VilleIUT *tiut[], int tLog, char ville[], int *trouve); //################ Fonction Menu ##################### diff --git a/Stest.c b/Stest.c index 22cddb6..997f7f2 100644 --- a/Stest.c +++ b/Stest.c @@ -1,6 +1,21 @@ #include"Ssae.h" int main(void){ - + VilleIUT* tab[20]; + VilleIUT a,b,c; + char test[20]; + int trouve = 0, pos; + strcpy(a.nom,"Clermont"); + strcpy(b.nom,"Lyon"); + strcpy(c.nom,"Paris"); + strcpy(test,"Lyon"); + a.lDept = NULL; + b.lDept = NULL; + c.lDept = NULL; + tab[0] = &a; + tab[1] = &b; + tab[2] = &c; + pos = rechercheIUT(tab,3,test,&trouve); + printf("%d %d\n",pos,trouve); return 0; } \ No newline at end of file