From 5ba89b5353c47d41908eea9a94a8dc91c5d5636b Mon Sep 17 00:00:00 2001 From: Kyllian Chabanon Date: Fri, 16 Dec 2022 11:34:59 +0100 Subject: [PATCH] Ajout de fonctions --- Partie_1/partie1.c | 72 ++++++++++++++++++++++++++++++++++++++++++++-- Partie_1/partie1.h | 11 ++++++- Partie_1/test.c | 4 ++- 3 files changed, 83 insertions(+), 4 deletions(-) diff --git a/Partie_1/partie1.c b/Partie_1/partie1.c index e901ee5..ceb13b6 100755 --- a/Partie_1/partie1.c +++ b/Partie_1/partie1.c @@ -45,6 +45,7 @@ void menuUtilisateur(void) printf("\t2 - Voir les départements dans chaque IUT\n"); printf("\t3 - Voir le nombre de places en première année\n"); printf("\t4 - Voir les IUT possédant un département particulier\n"); + printf("\t9 - Quitter\n"); printf("\nChoix : "); scanf("%d", &choix); switch (choix) @@ -67,7 +68,7 @@ void menuUtilisateur(void) break; case 9: c = true; - break; + return choixMenu(); default: printf("Option non reconnue. Veuillez recommencer.\n"); break; @@ -89,6 +90,7 @@ void menuAdministrateur(void) printf("\t4 - Lancer la phase de candidature\n"); printf("\t5 - Stopper la phase de candidature\n"); printf("\t6 - Modifier le responsable d'un département\n"); + printf("\t9 - Quitter\n"); printf("\nChoix : "); scanf("%d", &choix); switch (choix) @@ -118,11 +120,77 @@ void menuAdministrateur(void) // break; case 9: - c = true; + return choixMenu(); break; default: printf("Option non reconnue. Veuillez recommencer.\n"); break; } } +} + +ListeDept listenouv(void) +{ + return NULL; +} + +ListeDept insererEnTete(ListeDept l, char departement[], int nbP) +{ + MaillonDept *m; + m = (MaillonDept *)malloc(sizeof(MaillonDept)); + if (m == NULL) + { + printf("Fonction insererEnTete : problème malloc"); + exit(1); + } + strcpy(m->departement, departement); + m->nbP = nbP; + m->suiv = l; + return l; +} + +ListeDept chargeListeDept(VilleIUT *tiut[]) +{ + int i = 0; + ListeDept liste = listenouv(); + FILE *file = fopen("informationsIUT.don", "r"); + while (!feof(file)) + { + + } +} + +int chargementVilleIUT(VilleIUT *tiut[]) +{ + FILE *file = fopen("informationsIUT.don", "r"); + VilleIUT villeiut; + char ville[30], dept[30], nomResp[30]; + int nbP, i = 0; + if (file == NULL) + { + printf("Fonction chargementVilleIUT : Problème lors de l'ouverture du fichier informations.don"); + exit(-1); + } + while (!feof(file)) + { + tiut[i] = (VilleIUT *)malloc(sizeof(VilleIUT)); + if (tiut[i] == NULL) + { + printf("erreur malloc"); + exit(-1); + } + fscanf(file, "%s%s%d", tiut[i]->ville, dept, &nbP); + fgets(nomResp, 30, file); + i++; + } + fclose(file); + return i; +} + +void affichage(VilleIUT *tiut[], int nb) +{ + for (int i = 0; i < nb; i++) + { + printf("%s\n", tiut[i]->ville); + } } \ No newline at end of file diff --git a/Partie_1/partie1.h b/Partie_1/partie1.h index 4db756f..67f63ba 100755 --- a/Partie_1/partie1.h +++ b/Partie_1/partie1.h @@ -3,6 +3,15 @@ #include "../structures/structures.h" #include +/* Menus */ void choixMenu(void); void menuUtilisateur(void); -void menuAdministrateur(void); \ No newline at end of file +void menuAdministrateur(void); + +/* Fichier */ +int chargementVilleIUT(VilleIUT *tiut[]); +void affichage(VilleIUT *tiut[], int nb); + +/* File */ + +ListeDept listenouv(void); diff --git a/Partie_1/test.c b/Partie_1/test.c index 3a7db56..a818674 100755 --- a/Partie_1/test.c +++ b/Partie_1/test.c @@ -2,6 +2,8 @@ int main(void) { - choixMenu(); + VilleIUT *tiut[100]; + int nb = chargementVilleIUT(tiut); + affichage(tiut, nb); return 0; }