chargement et sauvegarde

master
d3friski 3 years ago
parent 09f72ec37c
commit 9ca06fa72d

@ -37,7 +37,7 @@ int chargIutDon(VilleIut *tVilleIut[], int nbMax, char nomFich[])
i = i + 1; i = i + 1;
} }
if(trouve==1) if(trouve==1)
ajouterDept(tVilleIut[indice]->lDept, nomDept, resp, nbP); tVilleIut[indice]->lDept = ajouterDept(tVilleIut[indice]->lDept, nomDept, resp, nbP);
fscanf(flot, "%s", nom); fscanf(flot, "%s", nom);
lireDep(flot, nomDept, &nbP, resp); lireDep(flot, nomDept, &nbP, resp);
} }
@ -75,3 +75,27 @@ int appartientIut(VilleIut *tVilleIut[], int nb, char nom[], int *trouve)
return i; return i;
} }
void sauvegarderFichierIutDon(VilleIut *tVilleIut[], int nbVille, char nomFich[])
{
FILE *flot;
int i=0;
flot = fopen(nomFich, "w");
if(flot==NULL)
{
printf("Probleme lors de l'ouverture du fichier\n");
exit(1);
}
while(i<nbVille)
{
printf("%d\n", i);
while(tVilleIut[i]->lDept != NULL)
{
printf("%s %s %d %s", tVilleIut[i]->nom, tVilleIut[i]->lDept->nomDept, tVilleIut[i]->lDept->nbP, tVilleIut[i]->lDept->resp);
fprintf(flot, "%s %s %d %s", tVilleIut[i]->nom, tVilleIut[i]->lDept->nomDept, tVilleIut[i]->lDept->nbP, tVilleIut[i]->lDept->resp);
tVilleIut[i]->lDept = tVilleIut[i]->lDept->suiv;
}
i = i + 1;
}
fclose(flot);
}

@ -0,0 +1 @@
Clermont-Ferrand Biologie 120 Perrier Yanic

@ -11,7 +11,6 @@ void testJean(void)
VilleIut *tIut[50] ; VilleIut *tIut[50] ;
nbvilles= chargIutDon(tIut, 50, "../donnees/iut.don"); nbvilles= chargIutDon(tIut, 50, "../donnees/iut.don");
//tIut = (VilleIut **)malloc(sizeof(VilleIut *)*nbvilles); //tIut = (VilleIut **)malloc(sizeof(VilleIut *)*nbvilles);
// strcpy(tIut[0]->nom, "John"); // strcpy(tIut[0]->nom, "John");
// strcpy(tIut[0]->ldept->nomDept, "Info"); // strcpy(tIut[0]->ldept->nomDept, "Info");
@ -21,4 +20,5 @@ void testJean(void)
afficheVillesIUT(tIut, nbvilles); afficheVillesIUT(tIut, nbvilles);
sauvegarderFichierIutDon(tIut, nbvilles, "result.don");
} }

Loading…
Cancel
Save