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