Création du fichier IUT.don et fonction afficherTIUT

master
Johnny.Ratton 2 years ago
parent e984e0b050
commit 5859d9606d

@ -0,0 +1,4 @@
Grenoble Informatique 112 Dupont Jean
Clermont-Ferrand Informatique 136 Simon Carine
Aurillac Bio-Informatique 56 Dufour Martine
Clermont-Ferrand Biologie 120 Montier Benoît

@ -11,6 +11,7 @@ int chargement(VilleIUT *tiut[],int *tMax)
if(flot == NULL) if(flot == NULL)
{ {
printf("Problème d'ouverture du fichier\n"); printf("Problème d'ouverture du fichier\n");
fclose(flot);
return -1; return -1;
} }
while(!feof(flot)) while(!feof(flot))
@ -19,14 +20,16 @@ int chargement(VilleIUT *tiut[],int *tMax)
if(v == NULL) if(v == NULL)
{ {
printf("Problème allocation ville lors de la lecture du fichier\n"); printf("Problème allocation ville lors de la lecture du fichier\n");
fclose(flot);
return -2; return -2;
} }
fscanf(flot, "%s", v->nom); fscanf(flot, "%s", v->nom);
pos = recherche(tiut, nb, v->nom, &trouve); pos = rechercheIUT(tiut, nb, v->nom, &trouve);
m = (MaillonDept *)malloc(sizeof(MaillonDept)); m = (MaillonDept *)malloc(sizeof(MaillonDept));
if(m == NULL) if(m == NULL)
{ {
printf("Problème allocation département lors de la lecture du fichier\n"); printf("Problème allocation département lors de la lecture du fichier\n");
fclose(flot);
return -3; return -3;
} }
*m = lireDep(flot); *m = lireDep(flot);
@ -58,12 +61,12 @@ MaillonDept lireDep(FILE *flot)
void afficherDep(MaillonDept m) void afficherDep(MaillonDept m)
{ {
printf("%s\t%d\t%s\n", m.dept, m.nbP, m.respAd); printf("\t%s\t%d\t%s\n", m.dept, m.nbP, m.respAd);
} }
void afficherVille(VilleIUT v) void afficherVille(VilleIUT v)
{ {
printf("%s\t", v.nom); printf("%s", v.nom);
while(v.lDept != NULL) while(v.lDept != NULL)
{ {
afficherDep(*v.lDept); afficherDep(*v.lDept);
@ -71,6 +74,14 @@ void afficherVille(VilleIUT v)
} }
} }
void afficherTIUT(VilleIUT *tiut[], int tLog)
{
int i = 0;
for(i = 0; i < tLog; i++)
{
afficherVille(*(tiut[i]));
}
}
void globale(void) void globale(void)
{ {

Loading…
Cancel
Save