You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.4 KiB

#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], nomResp[30];
int nbP, i = 0, 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(nomResp, 30, file);
trouve = recherche(tiut, i, ville);
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);
i++;
}
}
fclose(file);
return i;
}
int recherche(VilleIUT *tiut[], int nb, char val[])
{
for (int i = 0; i < nb; i++)
{
if (strcmp(tiut[i]->ville, val) == 0)
{
return 1;
}
}
return 0;
}
void affichage(VilleIUT *tiut[], int nb)
{
for (int i = 0; i < nb; i++)
{
printf("%s\n", tiut[i]->ville);
}
}