From 56dcf72d3ce29efaf527de028607dcdfde4502cb Mon Sep 17 00:00:00 2001 From: Yannis Doumir Fernandes Date: Fri, 20 Oct 2023 17:31:37 +0200 Subject: [PATCH] ADD chargementArticles() --- src/app/core_logic/responsable.c | 27 +++++++++++++++++++++++++++ src/app/core_logic/responsable.h | 3 +++ src/app/core_logic/testResponsable.c | 12 ++++++++++++ src/app/interface/interface_resp.c | 4 ++-- src/app/interface/interface_resp.h | 2 +- 5 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 src/app/core_logic/testResponsable.c diff --git a/src/app/core_logic/responsable.c b/src/app/core_logic/responsable.c index e69de29..6da8f11 100644 --- a/src/app/core_logic/responsable.c +++ b/src/app/core_logic/responsable.c @@ -0,0 +1,27 @@ +#include +#include "responsable.h" + +int chargementArticles(int tRef[], float tPoids[], float tVol[], float tPrix[], float tPhysique) +{ + int i=0, ref; + float volume, poids, prix; + FILE * fe; + fe = fopen("donnee/articles.txt", "r"); + if ( fe == NULL) + { + perror("fopen"); + } + while ( fscanf(fe,"%d %f %f %f", &ref, &poids, &volume, &prix) == 4) + { + if ( i == tPhysique ) + { + fprintf(stderr,"Tableau plein"); + } + tRef[i] = ref; + tPoids[i] = poids; + tVol[i] = volume; + tPrix[i] = prix; + i++; + } + return i; +} \ No newline at end of file diff --git a/src/app/core_logic/responsable.h b/src/app/core_logic/responsable.h index e69de29..8bee266 100644 --- a/src/app/core_logic/responsable.h +++ b/src/app/core_logic/responsable.h @@ -0,0 +1,3 @@ + + +int chargementArticles(int tRef[], float tPoids[], float tVol[], float tPrix[], float tPhysique); \ No newline at end of file diff --git a/src/app/core_logic/testResponsable.c b/src/app/core_logic/testResponsable.c new file mode 100644 index 0000000..9759553 --- /dev/null +++ b/src/app/core_logic/testResponsable.c @@ -0,0 +1,12 @@ +#include +#include "responsable.h" +#include "../interface/interface_resp.h" + +int main (void) +{ + int tPhysique = 10, tRef[10], tLogique = 0; + float tPoids[10], tVol[10], tPrix[10]; + tLogique = chargementArticles( tRef, tPoids, tVol, tPrix, tPhysique); + affichArticles( tRef, tPoids, tVol, tPrix, tLogique); + return 0; +} \ No newline at end of file diff --git a/src/app/interface/interface_resp.c b/src/app/interface/interface_resp.c index be2d6ef..650d3fc 100644 --- a/src/app/interface/interface_resp.c +++ b/src/app/interface/interface_resp.c @@ -1,12 +1,12 @@ #include #include "interface_resp.h" -void affichArticles( int tRef[], float tPoids[], float tVol[], float tPrix[], int tPhysique) +void affichArticles( int tRef[], float tPoids[], float tVol[], float tPrix[], int tLogique) { int i; printf("______________________________________\n"); printf("\t Liste des articles \n\n"); - for ( i = 0; i < tPhysique; ++i) + for ( i = 0; i < tLogique; ++i) { printf("\t %d %.2f %.2f %.2f\n\n", tRef[i], tPoids[i], tVol[i], tPrix[i]); } diff --git a/src/app/interface/interface_resp.h b/src/app/interface/interface_resp.h index ef6bc7a..480a299 100644 --- a/src/app/interface/interface_resp.h +++ b/src/app/interface/interface_resp.h @@ -1,4 +1,4 @@ -void affichArticles( int tRef[], float tPoids[], float tVol[], float tPrix[], int tPhysique); +void affichArticles( int tRef[], float tPoids[], float tVol[], float tPrix[], int tLogique); void affichUnArticle(int tRef[], float tPoids[], float tVol[], float tPrix[], int tLogique, int val); void affichUnClient(int tNumClient[], float tCagnotte[], int tSus[], int tLogique, int val); void affichUnClients(int tNumClient[], float tCagnotte[], int tSus[], int tLogique, int val); \ No newline at end of file