#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, insertPos; bool trouve; 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); resp[strlen(resp) -1] = '\0'; insertPos = rechercheVille(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 rechercheVille(VilleIUT *tiut[], int nb, char val[], bool *trouve) { int i; for (i = 0; i < nb; i++) { if (strcmp(tiut[i]->ville, val) == 0) { *trouve = true; return i; } } *trouve = false; return i; }