You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
118 lines
2.6 KiB
118 lines
2.6 KiB
|
|
#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;
|
|
|
|
} |