Commit test Sauvegarde réussie

master
Louis LABORIE 2 years ago
parent 725fb8f893
commit 4a58838cca

@ -587,12 +587,13 @@ int longueurListe(ListeDept l)
} }
void SauvegarderIUT(VilleIUT** tabV, int tailleL) { void SauvegarderIUT(VilleIUT** tabV, int tailleL) {
int i; int i, nbDept;
FILE* flot; FILE* flot;
flot = fopen("iut.txt","w"); flot = fopen("res.txt","w");
for (i = 0 ; i < tailleL ; i++) { for (i = 0 ; i < tailleL ; i++) {
fprintf(flot,"%s\n",tabV[i]->ville); fprintf(flot,"%s\n",tabV[i]->ville);
fprintf(flot,"%d\n",longueurListe(tabV[i]->idDept)); nbDept = longueurListe(tabV[i]->idDept);
fprintf(flot,"%d\n",&nbDept);
SauvegarderListe(tabV[i]->idDept,flot); SauvegarderListe(tabV[i]->idDept,flot);
free(tabV[i]); free(tabV[i]);
} }

@ -193,6 +193,43 @@ ListeDept rechercheDept(ListeDept l, char code[])
return rechercheDept(l->suiv, code); return rechercheDept(l->suiv, code);
} }
void SauvegarderIUT(VilleIUT** tabV, int tailleL) {
int i, nbDept;
FILE* flot;
flot = fopen("res.txt","w");
for (i = 0 ; i < tailleL ; i++) {
fprintf(flot,"%s\n",tabV[i]->ville);
nbDept = longueurListe(tabV[i]->idDept);
fprintf(flot,"%d\n",nbDept);
SauvegarderListe(tabV[i]->idDept,flot);
free(tabV[i]);
}
}
void SauvegarderListe(ListeDept l, FILE* flot) {
MaillonDept* tmp;
while (l->suiv != NULL) {
tmp = l;
fprintf(flot,"%s %d %s\n",l->departement,l->nbPlaces,l->nom);
l = l->suiv;
free(tmp);
}
fprintf(flot,"%s %d %s\n",l->departement,l->nbPlaces,l->nom);
free(l);
}
int longueurListe(ListeDept l)
{
int cpt = 0;
while (l != NULL)
{
cpt += 1;
l = l->suiv;
}
return cpt;
}
/* /*
ListeDept ajouterEnQueue(ListeDept l, int x) ListeDept ajouterEnQueue(ListeDept l, int x)
{ {

@ -0,0 +1,9 @@
Clermont-Ferrand
3
Informatique 130 Bouhours Cédric
Pokemon 7 Sacha Ketchum
Réseaux 5 Unmec Sympa
Lyon
2
GEA 8 Marx Karl
Jeux-videos 24 Kojima Hideo

@ -2,7 +2,8 @@
void globale(void) { void globale(void) {
int tailleL, i; int tailleL, i, nbP = 7;
char nom[30],depart[30];
VilleIUT** tab; VilleIUT** tab;
char nomFich[20]; char nomFich[20];
strcpy(nomFich,"iut.txt"); strcpy(nomFich,"iut.txt");
@ -11,7 +12,14 @@ void globale(void) {
printf("Ville : %s\n",tab[i]->ville); printf("Ville : %s\n",tab[i]->ville);
affichageListeDept(tab[i]->idDept); affichageListeDept(tab[i]->idDept);
} }
creationDept(tab,tailleL); printf("Nom du depart :\n");
scanf("%s%*c",depart);
printf("Nom responsable :\n");
fgets(nom,30,stdin);
nom[strlen(nom) - 1] = '\0';
insererDept(tab[0]->idDept,depart,nom,nbP);
printf("Ville : %s\n",tab[0]->ville);
affichageListeDept(tab[0]->idDept);
SauvegarderIUT(tab,tailleL); SauvegarderIUT(tab,tailleL);
} }

Loading…
Cancel
Save