parent
4a251ebdc9
commit
0ea0a59bba
Binary file not shown.
@ -0,0 +1,118 @@
|
||||
|
||||
#include "sae.h"
|
||||
|
||||
void ajoutClient (void)
|
||||
|
||||
{
|
||||
int numeroclient,suspension=0,verif;
|
||||
float cagnotte=0;
|
||||
|
||||
FILE *fichierclient;
|
||||
printf("ajout d'un client au programme de fidélité...\nquel est le numéro de ce client ?\n");
|
||||
scanf("%d",&numeroclient);
|
||||
while (numeroclient<0)
|
||||
{
|
||||
printf("le numéro du client ne peut être négatif , réessayez\n");
|
||||
scanf("%d",&numeroclient);
|
||||
}
|
||||
|
||||
fichierclient=fopen("fichierclient.don","r");
|
||||
|
||||
fscanf(fichierclient,"%d%*.f%*.d",&verif);
|
||||
|
||||
while (feof(fichierclient)==0)
|
||||
{
|
||||
if (verif==numeroclient)
|
||||
|
||||
while(verif==numeroclient)
|
||||
{
|
||||
printf("le numéro client existe déja ,veuillez ressaissir\n");
|
||||
scanf("%*c%d",&numeroclient);
|
||||
}
|
||||
|
||||
|
||||
fscanf(fichierclient,"%d%*.f%*.d",&verif);
|
||||
|
||||
}
|
||||
|
||||
fclose(fichierclient);
|
||||
fichierclient=fopen("fichierclient.don","a");
|
||||
printf("client ajouté au programme de fidélité ! \n");
|
||||
fprintf(fichierclient, "\t%d\t%*.2f\t%d\n",numeroclient,cagnotte,suspension );
|
||||
fclose(fichierclient);
|
||||
}
|
||||
|
||||
int supensioncarte (void)
|
||||
|
||||
{
|
||||
int tabNC [100]={0};
|
||||
float tabCAG [100]={0};
|
||||
int tabSUS [100]={0};
|
||||
|
||||
int nc,sus,compteur=0,taillemax=100,recherche,n;
|
||||
float cagnotte;
|
||||
|
||||
FILE *fichierClientmegacool;
|
||||
|
||||
n=compteurtaillelogique();
|
||||
|
||||
|
||||
fichierClientmegacool=fopen("fichierclient.don","r");
|
||||
fscanf(fichierClientmegacool,"%d%f%d",&nc,&cagnotte,&sus);
|
||||
while(feof(fichierClientmegacool)==0)
|
||||
{
|
||||
tabNC[compteur]=nc;
|
||||
tabCAG[compteur]=cagnotte;
|
||||
tabSUS[compteur]=sus;
|
||||
compteur=compteur+1;
|
||||
if (compteur>n)
|
||||
printf("erreur de taille");
|
||||
return 0;
|
||||
}
|
||||
fclose(fichierClientmegacool);
|
||||
|
||||
printf("quel carte souhaitez vous suspendre ou désuspendre (entrez numéro client)");
|
||||
scanf("%d",&recherche);
|
||||
while(recherche<0)
|
||||
{
|
||||
printf("numéro non valide , veuillez réessayez");
|
||||
scanf("%d",&recherche);
|
||||
}
|
||||
for (compteur=0;compteur<taillemax;compteur++)
|
||||
{
|
||||
if (tabNC[compteur]==recherche)
|
||||
printf("l'état de la carte de ce client est %d\n",tabSUS[compteur]);
|
||||
printf("modifiez l'état (0 pour non suspendu) (1 pour suspendu)\n");
|
||||
scanf("%d",&sus);
|
||||
tabSUS[compteur]=sus;
|
||||
|
||||
compteur=compteur+1;
|
||||
|
||||
if (compteur>n)
|
||||
printf("le client n'existe pas");
|
||||
return -2;
|
||||
}
|
||||
|
||||
for (compteur=0;compteur<n;compteur++)
|
||||
|
||||
fprintf(fichierClientmegacool, "\t%d\t%*.2f\t%d\n",tabNC[compteur],tabCAG[compteur],tabSUS[compteur]);
|
||||
fclose(fichierClientmegacool);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int compteurtaillelogique (void)
|
||||
|
||||
{
|
||||
int i =0;
|
||||
FILE *flot;
|
||||
flot=fopen("fichierclient.don","r");
|
||||
while(feof(flot)==0)
|
||||
i=i+1;
|
||||
fclose(flot);
|
||||
return i;
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
56 0.00 45
|
||||
96 0.00 45
|
||||
56 0.00 45
|
||||
56 0.00 45
|
||||
56 0.00 45
|
||||
56 0.00 45
|
||||
56 0.00 45
|
||||
56 0.00 45
|
||||
56 0.00 45
|
||||
67 0.00 45
|
||||
57 0.00 45
|
||||
58 0.00 45
|
||||
32 0.00 45
|
Binary file not shown.
@ -0,0 +1,5 @@
|
||||
#include <stdio.h>
|
||||
|
||||
void ajoutClient (void);
|
||||
int supensioncarte (void);
|
||||
int compteurtaillelogique (void);
|
@ -0,0 +1,4 @@
|
||||
#include <stdio.h>
|
||||
|
||||
void test(void);
|
||||
void ajoutArticle(void);
|
@ -0,0 +1,8 @@
|
||||
#include "sae.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
ajoutClient();
|
||||
supensioncarte();
|
||||
return 0; //cette instruction sert a dire au sys que prog termine
|
||||
}
|
Loading…
Reference in new issue