From 09b2c638600c5b11b217a56cb36c7dab564f1746 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20LAVERGNE?= Date: Tue, 17 Oct 2023 21:31:47 +0200 Subject: [PATCH] Ajout des fonctions de sauvegarde --- src/main.h | 4 ++-- src/traitement.c | 55 +++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 49 insertions(+), 10 deletions(-) diff --git a/src/main.h b/src/main.h index 278d388..593ac5e 100644 --- a/src/main.h +++ b/src/main.h @@ -11,11 +11,11 @@ #define tmaxClients 750 //! TRAITEMENT DES FICHIERS -void chargeDonnees(int reference[], float weight[], float volume[], float unitPrice[], int clientID[], float cagnotte[], int suspended[]); +void chargeDonnees(int *tLogArticle, int *tLogClient,int reference[], float weight[], float volume[], float unitPrice[], int clientID[], float cagnotte[], int suspended[]); int chargeArticles(int reference[], float weight[], float volume[], float unitPrice[]); int chargeClients(int clientID[], float cagnotte[], int suspended[]); -void sauvegardeDonnees(int reference[], float weight[], float volume[], float unitPrice[], int clientID[], float cagnotte[], int suspended[]); +void sauvegardeDonnees(int *tLogArticle, int *tLogClient, 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[]); diff --git a/src/traitement.c b/src/traitement.c index 58d7fdd..d44c6d7 100644 --- a/src/traitement.c +++ b/src/traitement.c @@ -17,12 +17,11 @@ int recherche(int val, int tab[], int tlog) // Recherche de l'index d'un id (de return -1; } -void chargeDonnees(int reference[], float weight[], float volume[], float unitPrice[], int clientID[], float cagnotte[], int suspended[]) +void chargeDonnees(int *tLogArticle, int *tLogClient,int reference[], float weight[], float volume[], float unitPrice[], int clientID[], float cagnotte[], int suspended[]) { - int tLogArticle, tLogClient; - chargeArticles(reference, weight, volume, unitPrice); - chargeClients(clieed); -}ntID, cagnotte, suspend + *tLogArticle = chargeArticles(reference, weight, volume, unitPrice); + *tLogClient = chargeClients(clientID, cagnotte, suspended); +} int chargeArticles(int reference[], float weight[], float volume[], float unitPrice[]) { @@ -95,8 +94,48 @@ int chargeClients(int clientID[], float cagnotte[], int suspended[]) return tL; } -void sauvegardeDonnees(int reference[], float weight[], float volume[], float unitPrice[], int clientID[], float cagnotte[], int suspended[]) +void sauvegardeDonnees(int *tLogArticle, int *tLogClient, int reference[], float weight[], float volume[], float unitPrice[], int clientID[], float cagnotte[], int suspended[]) +{ + *tLogArticle = sauvegardeArticles(reference, weight, volume, unitPrice); + *tLogClient = sauvegardeClients(clientID, cagnotte, suspended); +} + +int sauvegardeArticles(int reference[], float weight[], float volume[], float unitPrice[]) { - sauvegardeArticles(reference, weight, volume, unitPrice); - sauvegardeClients(clientID, cagnotte, suspended); + FILE *article; + article = fopen("articles.txt","w"); + if(article==NULL) + { + printf("ERREUR: Echec de l'ouverture en écriture de 'articles.txt'.\n"); + exit(1); + } + + int i; + for(i=0; i