parent
32e2ddaae5
commit
92dfa81df4
@ -0,0 +1,88 @@
|
||||
#include <stdio.h>
|
||||
#include "fRox.h"
|
||||
#define TAILLE 500
|
||||
|
||||
|
||||
//Fonction de chargement depuis le dossier client. Return 0 si dossier introuvable ou tableau plein, return i nombre d'éléments chargés
|
||||
int fchargement(int *tNoClient, char *tNomClient, char *tPreClient, int *tAge, char *tStatut, int tmax)
|
||||
{
|
||||
int noC, age, i=0;
|
||||
char prenom, nom, statut;
|
||||
FILE *fe;
|
||||
|
||||
fe = fopen ("donneClient.don", "r");
|
||||
if (fe == NULL)
|
||||
{
|
||||
printf("Le fichier est introuvable\n");
|
||||
return 0;
|
||||
|
||||
fscanf(fe,"%d%c%c%d%c", &noC, &nom, &prenom, &age, &statut);
|
||||
|
||||
while(!feof(fe))
|
||||
{
|
||||
if (i == tmax)
|
||||
{
|
||||
printf("Les tableaux sont pleins");
|
||||
return 0;
|
||||
}
|
||||
|
||||
tNoClient[i] = noC;
|
||||
tNomClient[i] = nom;
|
||||
tPreClient[i] = prenom;
|
||||
tAge[i] = age;
|
||||
tStatut[i] = statut;
|
||||
i++;
|
||||
fscanf(fe,"%d%c%c%d%c", &noC, &nom, &prenom, &age, &statut);
|
||||
}
|
||||
}
|
||||
fclose(fe);
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
//Fonction recherche, (*coderet = 1 si trouvé, = 0 si pas trouvé.) (*rang = rang a laquel se trouve ou doit se trouver la valeur)
|
||||
void fRecherche(int *tNoClient, int n, int noClient, int *coderet, int *rang)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 0; i < n; i++)
|
||||
{
|
||||
if(tNoClient[i] == noClient)
|
||||
{
|
||||
*coderet = 1;
|
||||
*rang = i;
|
||||
return;
|
||||
}
|
||||
if(tNoClient[i] > noClient)
|
||||
|
||||
*rang = i;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Affichage D'UN client avec toutes ses données.
|
||||
void fAffichage1Client(int *tNoClient, char *tNomClient, char *tPreClient, int *tAge, char *tStatut, int n, int noClient )
|
||||
{
|
||||
int i, coderet, rang, trouve, NonTrouve;
|
||||
|
||||
|
||||
fRecherche(tNoClient, n, noClient, &coderet, &rang);
|
||||
|
||||
trouve = coderet;
|
||||
|
||||
while (trouve == 0)
|
||||
{
|
||||
if(coderet == 0)
|
||||
{
|
||||
printf("Le numero client n'a pas été trouvé \n");
|
||||
printf("Veuillez entrer a nouveau le N° Client ou taper -1 pour annuler\n");
|
||||
scanf("%d", &NonTrouve);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
printf(" N° Client\t Nom\t Prénom\t Age\t Tarif\n");
|
||||
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
#include <stdio.h>
|
||||
#define TAILLE 500
|
||||
|
||||
int fchargement(int *tNoClient, char *tNomClient, char *tPreClient, int *tAge, char *tStatut, int tmax);
|
||||
void fRecherche(int *tNoClient, int n, int noClient, int *coderet, int *rang);
|
||||
void fAffichage1Client(int *tNoClient, char *tNomClient, char *tPreClient, int *tAge, char *tStatut, int n, int noClient );
|
Binary file not shown.
@ -0,0 +1,11 @@
|
||||
#include <stdio.h>
|
||||
#include "fRox.h"
|
||||
#define TAILLE 500
|
||||
|
||||
void main(void)
|
||||
{ int *tNoClient, *tAge, toto;
|
||||
char *tNomClient, *tPreClient, *tStatut;
|
||||
|
||||
toto =fchargement(tNoClient, tNomClient, tPreClient, tAge, tStatut, 50);
|
||||
printf("%d\n", toto);
|
||||
}
|
Loading…
Reference in new issue