Ajout des fonctions de sauvegarde

doc
Rémi LAVERGNE 2 years ago
parent f9189eff96
commit 09b2c63860
No known key found for this signature in database
GPG Key ID: 7BCBAE9031E39160

@ -11,11 +11,11 @@
#define tmaxClients 750 #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 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 chargeArticles(int reference[], float weight[], float volume[], float unitPrice[]);
int chargeClients(int clientID[], float cagnotte[], int suspended[]); 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 sauvegardeArticles(int reference[], float weight[], float volume[], float unitPrice[]);
void sauvegardeClients(int clientID[], float cagnotte[], int suspended[]); void sauvegardeClients(int clientID[], float cagnotte[], int suspended[]);

@ -17,12 +17,11 @@ int recherche(int val, int tab[], int tlog) // Recherche de l'index d'un id (de
return -1; 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; *tLogArticle = chargeArticles(reference, weight, volume, unitPrice);
chargeArticles(reference, weight, volume, unitPrice); *tLogClient = chargeClients(clientID, cagnotte, suspended);
chargeClients(clieed); }
}ntID, cagnotte, suspend
int chargeArticles(int reference[], float weight[], float volume[], float unitPrice[]) int chargeArticles(int reference[], float weight[], float volume[], float unitPrice[])
{ {
@ -95,8 +94,48 @@ int chargeClients(int clientID[], float cagnotte[], int suspended[])
return tL; 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); FILE *article;
sauvegardeClients(clientID, cagnotte, suspended); 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<tLogArticle; i++)
{
fprintf(article, "%d %f %f %f\n", reference[i], weight[i], volume[i], unitPrice[i]);
}
fclose(article);
return tLogArticle;
}
int sauvegardeClients(int clientID[], float cagnotte[], int suspended[])
{
FILE *client;
client = fopen("clients.txt","w");
if(client==NULL)
{
printf("ERREUR: Echec de l'ouverture en écriture de 'clients.txt'.\n");
exit(1);
}
int i;
for(i=0; i<tLogClient; i++)
{
fprintf(client, "%d %f %d\n", clientID[i], cagnotte[i], suspended[i]);
}
fclose(client);
return tLogClient;
} }
Loading…
Cancel
Save