diff --git a/src/annexe/saeAnnexe.c b/src/annexe/saeAnnexe.c index 1006507..28a3b1d 100644 --- a/src/annexe/saeAnnexe.c +++ b/src/annexe/saeAnnexe.c @@ -13,18 +13,19 @@ void menu(void){ printf("#--------------------------------------------------------------------#\n\n"); printf("Codes pour accéder aux différents profils :\n\n"); printf("C : Consultation.\n"); - printf("A : Administrateur.\n\n"); + printf("A : Administrateur.\n"); + printf("S : Sauvegarder.\n\n"); printf("#--------------------------------------------------------------------#\n\n"); printf("Choisissez votre session : "); } int loadIUT(VilleIUT** tiut){ FILE* f=fopen("Etudiants.bin","rb"); - MaillonDep* m; if(f==NULL){ perror("fopen"); exit(errno); } + MaillonDep* m; int tlogi; fread(&tlogi,sizeof(int),1,f); for(int i=0; iville,sizeof(char),31,f); + } + for(int i=0; ildept); + fwrite(&nbIUTs,sizeof(int),1,f); + m=tiut[i]->ldept; + for(int j=0; jdepartement,sizeof(char),31,f); + fwrite(&m->nbp,sizeof(int),1,f); + fwrite(m->resp,sizeof(char),51,f); + m=m->suivant; + } + } + printf("Les IUTs enregistrés ont bien étés sauvegardés."); +} + int rechercheTabPtVilleIUT(VilleIUT* tab[],int lTab,char* mot){ if(!lTab){ fprintf(stderr,"Erreur, Pas d'éléments dans le tableau !"); @@ -80,8 +106,14 @@ int existeDep(MaillonDep* liste, char* dep){ return 0; } -int recherche(MaillonDep* liste, char* mot){ - return 1;//A Faire ! +int longueurListe(MaillonDep* liste){ + MaillonDep* m=liste; + int i=0; + while(m!=Null){ + m=m->suivant; + i++; + } + return i; } //Pile diff --git a/src/annexe/saeAnnexe.h b/src/annexe/saeAnnexe.h index 3ea8b4c..d6854fe 100644 --- a/src/annexe/saeAnnexe.h +++ b/src/annexe/saeAnnexe.h @@ -29,7 +29,9 @@ typedef struct file* File; // // // void menu(void); // // -int loadIUT(VilleIUT** tiut); //Fichier Binaire. // +int loadIUT(VilleIUT** tiut); // + // +void saveIUT(VilleIUT** tiut, int tlogi); // // int rechercheTabPtVilleIUT(VilleIUT* tab[],int lTab,char* mot); // // @@ -38,7 +40,7 @@ int rechercheTabPtVilleIUT(VilleIUT* tab[],int lTab,char* mot); // //Fonctions relatives aux listes chaînées : --// // int existeDep(MaillonDep* liste, char* dep); // // // // -int recherche(MaillonDep* liste, char* mot); // // +int longueurListe(MaillonDep* liste); // // //--------------------------------------------// // // // diff --git a/src/saeMain.c b/src/saeMain.c index 7e69780..c600770 100644 --- a/src/saeMain.c +++ b/src/saeMain.c @@ -24,7 +24,12 @@ int main(void) reset(); menuAdmin(tiut,tlogi); reset(); + break; + case 'S': + saveIUT(tiut,tlogi); + reset(); } - //save(); + saveIUT(tiut,tlogi); + printf("L'application se ferme ..."); return 0; } \ No newline at end of file