Fonction evann

master
Evann ABRIAL 2 years ago
parent e14864a4fb
commit 4d7cfe6cfa

@ -1,122 +1,195 @@
#include <stdio.h> #include <stdio.h>
#include "sae.h" #include "evsae.h"
#include <stdlib.h> #include <stdlib.h>
void menu (void) void menu (void)
{ {
char choix, retourmenu; char choix, retourmenu;
int VSUIVANTE; int VSUIVANTE, next;
FILE *fx; FILE *fx;
fx=fopen("x.don","r"); fx=fopen("x.don","r");
if (fx==NULL)
{printf("erreur"); if (fx==NULL)
return;} {printf("erreur");
return;}
while(feof(fx)) VSUIVANTE=0;
{
fscanf(fx,"%d",&VSUIVANTE); while(!feof(fx))
} {
fscanf(fx, "%d", &next);
printf("\nQue souhaitez vous faire?\n");
printf("\n1- Créer un compte\n"); if ( next> VSUIVANTE)
printf("2- Presenter sa carte\n"); {
printf("\nTapez h pour une aide\n"); VSUIVANTE=next;
scanf("%c%*c", &choix); }
}
if (choix == 'h')
{ printf("\nQue souhaitez vous faire?\n");
printf("\n\tBienvenue dans notre application!\n"); printf("\n1- Créer un compte\n");
printf("\nVous êtes arrivées dans le menu de notre incroyable salle de sport\n"); printf("2- Presenter sa carte\n");
printf("Tapez le nombre au début de la liste des fonctionnalitées pour y accéder"); printf("Controle C pour quitter");
printf("\nSi vous êtes nouveau, nous vous conseillons de créer un compte en tapant 1 dan le menu"); printf("\nTapez h pour une aide\n");
printf("\nTapez O pour retourner au menu principal\n");
scanf("%c%*c",&retourmenu); scanf("%*c%c%*c", &choix);
if (retourmenu == 'O') while ( choix != 'h' && choix != '1' && choix != '2')
{
menu(); printf("\nEntrez soit h, soit 1, soit 2.\t");
} scanf("%c", &choix);
}
if (choix == '1')
{ if (choix == 'h')
creationCompte( &VSUIVANTE); {
} printf("\n\tBienvenue dans notre application!\n");
printf("\nVous êtes arrivées dans le menu de notre incroyable salle de sport\n");
if (choix == '2') printf("Tapez le nombre au début de la liste des fonctionnalitées pour y accéder");
{ printf("\nSi vous êtes nouveau, nous vous conseillons de créer un compte en tapant 1 dan le menu");
printf("gogogogo"); printf("\nTapez O pour retourner au menu principal\n");
//Compte() scanf("%c",&retourmenu);
}
} while ( retourmenu != 'O')
{
void c(void) printf("\nTapez la lettre O pour revenir au menu.\t");
{ scanf("%*c%c%*c", &retourmenu);
int x=10000000, i=0; }
FILE *fe;
fe = fopen("nclient.don","w"); if (retourmenu == 'O')
menu();
for (i=0; i<x; i++)
{ }
fprintf(fe,"\n%d",i);
} if (choix == '1')
} {
creationCompte( &VSUIVANTE);
}
void creationCompte(int *VSUIVANTE)
{ if (choix == '2')
char nom[15], prenom[20], categorie, gen, retour; {
int age, nclient; printf("gogogogo");
FILE *fe, *fx, *fn; //Compte()
fe= fopen("donneClient.don", "a"); }
fn= fopen("nclient.don", "r");
fx= fopen("x.don","a"); }
fprintf(fx,"%d", *VSUIVANTE);
/*
if (fe==NULL) void c(void)
{ {
printf(" Erreur ouverture fichier"); int x=10000000, i=0;
} FILE *fe;
fe = fopen("nclient.don","w");
printf("\nEntrez votre nom\n");
scanf("%s%*c", nom); for (i=0; i<x; i++)
{
printf("\nEntrez votre prenom\n"); fprintf(fe,"\n%d",i);
scanf("%s%*c", prenom); }
}
printf("\nEntrez votre age\n");
scanf("%d%*c", &age); */
printf("Avez-vous un tarif spécial: Etudiant(E), Senior(S), aucun(A)?\n"); void creationCompte(int *VSUIVANTE)
scanf("%c%*c", &categorie); {
char nom[15], prenom[20], categorie, gen, retour;
int age, nclient;
fprintf(fe,"%d\t",*VSUIVANTE); FILE *fe, *fx, *fn;
fprintf(fe,"%s\t",nom); fe= fopen("donneClient.don", "a");
fprintf(fe,"%s\t",prenom); fx= fopen("x.don","a");
fprintf(fe,"%d\t",age);
fprintf(fe,"%c\n",categorie);
if (fe==NULL)
printf("Retour menu?(O/N)\n"); {
scanf("%c%*c", &retour); printf(" Erreur ouverture fichier");
}
if (retour == 'O')
menu(); printf("\nEntrez votre nom\n");
else scanf("%s%*c", nom);
return;
} printf("\nEntrez votre prenom\n");
scanf("%s%*c", prenom);
printf("\nEntrez votre age\n");
scanf("%d%*c", &age);
printf("Avez-vous un tarif spécial: Etudiant(E), Senior(S), aucun(A)?\n");
scanf("%c%*c", &categorie);
fprintf(fe,"\n%d\t",*VSUIVANTE);
fprintf(fe,"%s\t",nom);
fprintf(fe,"%s\t",prenom);
fprintf(fe,"%d\t",age);
fprintf(fe, "0\t"); //état de la carte
fprintf(fe, "0\t"); //activité
fprintf(fe, "0\t"); //passé ou pas
fprintf(fe, "30\t"); //point acheté
fprintf(fe, "0\t"); //point cumulé
fprintf(fe,"%c",categorie);
*VSUIVANTE=*VSUIVANTE+1;
fprintf(fx,"\n%d",*VSUIVANTE);
printf("Ajoutez un contact?(O/N)\n");
scanf("%c%*c", &retour);
if (retour == 'O')
creationCompte(VSUIVANTE);
else
return;
}
void fRecherche(int *tAd, int n, int noClient, int *coderet, int *rang)
{
int i;
for(i = 0; i < n; i++)
{
if(tAd[i] == noClient)
{
*coderet = 1;
*rang = i;
return;
}
if(tAd[i] > noClient)
*rang = i;
return;
}
}
void changementEtatCarte ( int *tAd , int *tstate)
{
int nchoix
printf("\nNouvel état de la carte:");
printf("\nDésactiver(0)")
printf("\nActiver(1)")
scanf("%c%*c",&nchoix
if (nchoix == 'D')
{
printf("\Mauvais comportement(M)")
printf("\Carte perdu(P)")
}

@ -1,4 +1,4 @@
#include <stdio.h> #include <stdio.h>
void menu (void); void menu ();
void creationCompte(int *VSUIVANTE); void creationCompte(int *VSUIVANTE);
void c(void); void fRecherche(int *tAd, int n, int noClient, int *coderet, int *rang);

@ -0,0 +1,9 @@
#include <stdio.h>
#include "evsae.h"
int main (void)
{
//c();
menu();
return 0;
}

BIN
test

Binary file not shown.

10
x.don

@ -1,2 +1,8 @@
0 0
-2091757392-2091757392-2085961056 1
1
2
3
4
5
6
Loading…
Cancel
Save