Création des fonctions chargeArticles & chargeClients

doc
Rémi LAVERGNE 2 years ago
parent 001dcc5729
commit c5c8dbfd80
No known key found for this signature in database
GPG Key ID: 8861D8A4AD21A032

@ -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);

@ -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);
}
Loading…
Cancel
Save