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.

89 lines
1.8 KiB

#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");
}