#include "partie1.h" /* ListeDept chargeListeDept(VilleIUT *tiut[]) { int i = 0; ListeDept liste = listenouv(); FILE *file = fopen("informationsIUT.txt", "r"); while (!feof(file)) { } }*/ int chargementVillesIUT(VilleIUT *tiut[]) { FILE *file = fopen("informationsIUT.txt", "r"); char ville[30], dept[30], resp[30]; int nbP, i = 0, trouve, insertPos; if (file == NULL) { printf("Fonction chargementVillesIUT : Problème lors de l'ouverture du fichier informationsIUT.txt"); exit(-1); } while (!feof(file)) { fscanf(file, "%s%s%d", ville, dept, &nbP); fgets(resp, 30, file); insertPos = recherche(tiut, i, ville, &trouve); if (trouve == 0) { tiut[i] = (VilleIUT *)malloc(sizeof(VilleIUT)); if (tiut[i] == NULL) { printf("Fonction chargementVillesIUT : Problème lors du malloc"); exit(-1); } strcpy(tiut[i]->ville, ville); tiut[i]->ldept = listenouv(); tiut[i]->ldept = inserer(tiut[i]->ldept, dept, nbP, resp); i++; } else { tiut[insertPos]->ldept = inserer(tiut[insertPos]->ldept, dept, nbP, resp); } } fclose(file); return i; } int recherche(VilleIUT *tiut[], int nb, char val[], int *trouve) { int i; for (i = 0; i < nb; i++) { if (strcmp(tiut[i]->ville, val) == 0) { *trouve = 1; return i; } } *trouve = 0; return i; } void affichageVillesIUT(VilleIUT *tiut[], int nb) { printf("Voici les villes qui ont un IUT :\n"); for (int i = 0; i < nb; i++) { printf("\t%s\n", tiut[i]->ville); } } void affichageDeptIUT(VilleIUT *tiut[], int nb) { printf("Voici les départements présents dans chaque IUT :\n"); for (int i = 0; i < nb; i++) { printf("\t%s :\n", tiut[i]->ville); afficherDept(tiut[i]->ldept); } }