From 26889a4ee5e613ecfb5e5091cbc173b72b79dfdd Mon Sep 17 00:00:00 2001 From: mahersan Date: Fri, 20 Oct 2023 17:15:19 +0200 Subject: [PATCH] Added chargerClient --- src/app/core_logic/client.c | 25 ++++++++++++------------- src/app/core_logic/client.h | 2 +- src/main.c | 2 ++ 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/app/core_logic/client.c b/src/app/core_logic/client.c index 04040fd..d5e75e2 100644 --- a/src/app/core_logic/client.c +++ b/src/app/core_logic/client.c @@ -4,21 +4,20 @@ #include "client.h" -void afficherDonneesClient() { - FILE *fichier = fopen("donnee/client.txt", "r"); - int numeroClient; - float cagnotte; - int suspendu; - - if (fichier == NULL) { - fprintf(stderr, "Erreur lors de l'ouverture du fichier"); +void chargerClient(int tNumClient[], float tCagnotte[], int tSus[], int *tLogique) +{ + FILE *fic; + int i; + fic = fopen("donnee/client.txt", "r"); + if (fic == NULL) + { + perror("fopen"); exit(EXIT_FAILURE); } - while (fscanf(fichier, "%d%f%d", &numeroClient, &cagnotte, &suspendu) == 3) { - printf("Client %d, Cagnotte %.2f, Suspendu: %s\n", - numeroClient, cagnotte, (suspendu == 0) ? "Non" : "Oui"); + while (fscanf(fic, "%d %f %d", &tNumClient[*tLogique], &tCagnotte[*tLogique], &tSus[*tLogique]) != EOF) + { + (*tLogique)++; } - - fclose(fichier); + fclose(fic); } \ No newline at end of file diff --git a/src/app/core_logic/client.h b/src/app/core_logic/client.h index aff2be5..e173a26 100644 --- a/src/app/core_logic/client.h +++ b/src/app/core_logic/client.h @@ -8,6 +8,6 @@ #include #include -void afficherDonneesClient(); +void chargerClient(int tNumClient[], float tCagnotte[], int tSus[], int *tLogique); #endif //SAE_101_CLIENT_H diff --git a/src/main.c b/src/main.c index 106da06..d65ed5f 100644 --- a/src/main.c +++ b/src/main.c @@ -26,5 +26,7 @@ int main(){ //case 1: global_resp(); case 2: global_client(); } + + chargerClient(); return 0; }