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.
69 lines
1.8 KiB
69 lines
1.8 KiB
#include "Fonctions.h"
|
|
|
|
int Ouverture(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int tNbActivitesJour[], int tDate[], int tmax, int *pasAct)
|
|
{
|
|
int pasMembres;
|
|
pasMembres = OuvertureMembres(tNoCarte, tage, tPointsCarte, tCarteActive, tmax);
|
|
*pasAct = OuvertureActivitesJour(tNbActivitesJour, tDate, tmax);
|
|
return pasMembres;
|
|
}
|
|
|
|
int OuvertureMembres(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int tmax)
|
|
{
|
|
int i = 0;
|
|
int NoCarte, age, pointsCarte, CarteActive;
|
|
FILE *flot;
|
|
flot = fopen("membres.don", "r");
|
|
if (flot == NULL)
|
|
{
|
|
printf("Pb d'ouverture du fichier membres.don\n");
|
|
return -1;
|
|
}
|
|
fscanf(flot, "%d%d%d%d", &NoCarte, &age, &pointsCarte, &CarteActive);
|
|
while (!feof(flot))
|
|
{
|
|
if (i == tmax)
|
|
{
|
|
printf("Tableau plein\n");
|
|
fclose(flot);
|
|
return -1;
|
|
}
|
|
tNoCarte[i] = NoCarte;
|
|
tage[i] = age;
|
|
tPointsCarte[i] = pointsCarte;
|
|
tCarteActive[i] = CarteActive;
|
|
fscanf(flot, "%d%d%d%d", &NoCarte, &age, &pointsCarte, &CarteActive);
|
|
i++;
|
|
}
|
|
fclose(flot);
|
|
return i;
|
|
}
|
|
|
|
int OuvertureActivitesJour(int tNbActivitesJour[], int tDate[], int tmax)
|
|
{
|
|
int i = 0;
|
|
int Date, nbActivitesJour;
|
|
FILE *jour;
|
|
jour = fopen("ActivitesJour.don", "r");
|
|
if (jour == NULL)
|
|
{
|
|
printf("Pb d'ouverture du fichier ActivitesJour.don\n");
|
|
return -1;
|
|
}
|
|
fscanf(jour, "%d%d", &Date, &nbActivitesJour);
|
|
while (!feof(jour))
|
|
{
|
|
if (i == tmax)
|
|
{
|
|
printf("Tableau plein\n");
|
|
fclose(jour);
|
|
return -1;
|
|
}
|
|
tDate[i] = Date;
|
|
tNbActivitesJour[i] = nbActivitesJour;
|
|
fscanf(jour, "%d%d", &Date, &nbActivitesJour);
|
|
i++;
|
|
}
|
|
fclose(jour);
|
|
return i;
|
|
} |