diff --git a/SAEl.c b/SAEl.c index f2ae313..bdff3d9 100644 --- a/SAEl.c +++ b/SAEl.c @@ -1,4 +1,4 @@ -#include "SAE.h" +#include "SAEl.h" ListeDept creerListeDept(void) { @@ -35,9 +35,9 @@ VilleIUT **chargementVille(char *nomFich, int tphys, int *tailleL) { fscanf(flot, "%d", &nbDept); printf("Nombre de dep : %d\n",nbDept); + tabV[*tailleL]->idDept = creerListeDept(); while (i < nbDept) { - tabV[*tailleL]->idDept = creerListeDept(); tabV[*tailleL]->idDept = traiterDept(tabV[*tailleL]->idDept, flot); i += 1; } @@ -70,12 +70,11 @@ ListeDept traiterDept(ListeDept l, FILE *flot) { char nom[30], dept[30]; int nbPlaces; - fgets(dept, 30, flot); - dept[strlen(dept) - 1] = '\0'; - fscanf(flot, "%d", &nbPlaces); + fscanf(flot,"%s %d",dept,&nbPlaces); fgets(nom, 30, flot); nom[strlen(nom) - 1] = '\0'; - l = inserer(l, dept, nom, nbPlaces); + printf("Nom du départ : %s\n",dept); + l = insererDept(l, dept, nom, nbPlaces); return l; } @@ -107,12 +106,12 @@ void affichageListeDept(ListeDept l) // itératif ListeDept insererDept(ListeDept l, char *dept, char *nom, int nbP) { // récursif if (l == NULL) - return ajouterEnTete(l, dept, nom, nbP); + return ajouterEnTeteDept(l, dept, nom, nbP); if ((strcmp(dept,l->departement)) < 0) - return ajouterEnTete(l, dept, nom, nbP); + return ajouterEnTeteDept(l, dept, nom, nbP); if ((strcmp(dept,l->departement)) == 0) return l; - l->suiv = inserer(l->suiv, dept, nom, nbP); + l->suiv = insererDept(l->suiv, dept, nom, nbP); return l; } @@ -140,7 +139,7 @@ ListeDept supprimerDept(ListeDept l, char *code) return l; if ((strcmp(code,l->departement)) == 0) return supprimerEnTêteDept(l); - l->suiv = supprimer(l->suiv, code); + l->suiv = supprimerDept(l->suiv, code); return l; } @@ -190,7 +189,7 @@ ListeDept rechercheDept(ListeDept l, char code[]) if ((strcmp(code,l->departement)) < 0) return NULL; if (strcmp(code,l->departement)==0) - return l->departement; + return l; return rechercheDept(l->suiv, code); } diff --git a/SAEl.h b/SAEl.h index 063124d..ca4db57 100644 --- a/SAEl.h +++ b/SAEl.h @@ -1,6 +1,7 @@ #include #include #include +#include typedef struct maillondept { @@ -20,9 +21,9 @@ typedef struct { ListeDept creerListeDept(void); -ListeDept ajouterEnTete(ListeDept l, char* dept, char* nom, int nbP); +ListeDept ajouterEnTeteDept(ListeDept l, char* dept, char* nom, int nbP); -ListeDept inserer(ListeDept l, char *dept, char *nom, int nbP); +ListeDept insererDept(ListeDept l, char *dept, char *nom, int nbP); void affichageListeDept(ListeDept l); @@ -32,3 +33,5 @@ ListeDept traiterDept(ListeDept l, FILE *flot); VilleIUT** chargementVille(char* nomFich, int tphys, int* tailleL); +ListeDept supprimerDept(ListeDept l, char *code); + diff --git a/iut.txt b/iut.txt index da41eb7..a1dd15a 100644 --- a/iut.txt +++ b/iut.txt @@ -1,16 +1,8 @@ Clermont-Ferrand 2 -Informatique -130 -Bouhours Cédric -Réseaux -5 -Unmec Sympa +Informatique 130 Bouhours Cédric +Réseaux 5 Unmec Sympa Lyon 2 -Jeux-videos -24 -Kojima Hideo -GEA -8 -Macron Emmanuel \ No newline at end of file +Jeux-videos 24 Kojima Hideo +GEA 8 Macron Emmanuel diff --git a/testSAE.c b/testSAE.c index ccc908b..261052c 100644 --- a/testSAE.c +++ b/testSAE.c @@ -1 +1,21 @@ -#include "SAEl.h" \ No newline at end of file +#include "SAEl.h" + + +void globale(void) { + int tailleL, i; + VilleIUT** tab; + char nomFich[20]; + strcpy(nomFich,"iut.txt"); + printf("charg\n"); + tab = chargementVille(nomFich,30,&tailleL); + printf("affich\n"); + for(i = 0 ; i < tailleL ; i++) { + printf("Ville : %s\n",tab[i]->ville); + affichageListeDept(tab[i]->idDept); + } +} + +int main(void) { + globale(); + return 0; +} \ No newline at end of file