From c5c8dbfd8080cce0cf9ee3db59cc93d80fec3dd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20LAVERGNE?= Date: Mon, 16 Oct 2023 14:00:24 +0200 Subject: [PATCH] =?UTF-8?q?Cr=C3=A9ation=20des=20fonctions=20chargeArticle?= =?UTF-8?q?s=20&=20chargeClients?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.h | 8 ++++++- src/traitement.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 59 insertions(+), 3 deletions(-) diff --git a/src/main.h b/src/main.h index d36f66e..92b8862 100644 --- a/src/main.h +++ b/src/main.h @@ -5,12 +5,18 @@ #define tmaxArticles 500 #define tmaxClients 750 -// TRAITEMENT DES FICHIERS +//! TRAITEMENT DES FICHIERS void chargeDonnees(int reference[], float weight[], float volume[], float unitPrice[], int clientID[], float cagnotte[], int suspended[]); void chargeArticles(int reference[], float weight[], float volume[], float unitPrice[]); void chargeClients(int clientID[], float cagnotte[], int suspended[]); +void sauvegardeDonnees(int reference[], float weight[], float volume[], float unitPrice[], int clientID[], float cagnotte[], int suspended[]); +void sauvegardeArticles(int reference[], float weight[], float volume[], float unitPrice[]); +void sauvegardeClients(int clientID[], float cagnotte[], int suspended[]); + +//! GESTION CLIENTS void inputClient(void); void modifyClient(void); +//! GESTION STOCKS void inputItem(void); \ No newline at end of file diff --git a/src/traitement.c b/src/traitement.c index 4d88e17..8cb466d 100644 --- a/src/traitement.c +++ b/src/traitement.c @@ -15,6 +15,31 @@ void chargeArticles(int reference[], float weight[], float volume[], float unitP printf("ERREUR: Echec de l'ouverture en lecture de 'articles.txt'.\n"); exit(1); } + + int ref, tL=0; + float w, v, up; + + fscanf(article, "%d %f %f %f", &ref, &w, &v, &up); + while(!feof(article)) + { + if(tL < tmaxArticles) + { + printf("Tableau trop petit.\n"); + return tL; + } + + reference[tL] = ref; + weight[tL] = w; + volume[tL] = v; + unitPrice[tL] = up; + + tL++; + + fscanf(article, "%d %f %f %f", &ref, &w, &v, &up); + } + + fclose(article); + return tL; } void chargeClients(int clientID[], float cagnotte[], int suspended[]) @@ -26,9 +51,34 @@ void chargeClients(int clientID[], float cagnotte[], int suspended[]) printf("ERREUR: Echec de l'ouverture en lecture de 'clients.txt'.\n"); exit(1); } + + int id, sus, tL=0; + float cag; + + fscanf(client, "%d %f %d", &id, &cag, &sus); + while(!feof(client)) + { + if(tL < tmaxArticles) + { + printf("Tableau trop petit.\n"); + return tL; + } + + clientID[tL] = id; + cagnotte[tL] = cag; + suspended[tL] = sus; + + tL++; + + fscanf(client, "%d %f %d", &id, &cag, &sus); + } + + fclose(client); + return tL; } -void sauvegardeDonnees() +void sauvegardeDonnees(int reference[], float weight[], float volume[], float unitPrice[], int clientID[], float cagnotte[], int suspended[]) { - + sauvegardeArticles(reference, weight, volume, unitPrice); + sauvegardeClients(clientID, cagnotte, suspended); } \ No newline at end of file