diff --git a/SAE.c b/SAE.c index ea3d41e..a72435d 100644 --- a/SAE.c +++ b/SAE.c @@ -1,20 +1,25 @@ #include "SAE.h" -int Ouverture(int tNoCarte[],int tnom[], int tprenom[], int tage[], int tPointsCarte[], int tCarteActive[], int tNbActivitéesJour[]) +int Ouverture(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int tNbActivitesJour[], int tDate[], int tmax) { - int NoCarte, nom, prenom, age, pointsCarte, CarteActive, nbActivitéesJour; - int tmax = 500, i = 0; - int tNoCarte[500], tage[500], tPointsCarte[500], tNbActivitéesJour[500]; - char tnom[500], tprenom[500]; - char tCarteActive[500]; - FILE *flot; + int i = 0, j = 0; + int NoCarte, age, pointsCarte, CarteActive; + int Date, nbActivitesJour; + FILE *flot *jour; flot = fopen("membres.don", "r"); + jour = fopen("ActivitesJour.don", "r"); if(flot == NULL) { printf("Pb d'ouverture du fichier membres.don\n"); return -1; } + if(jour == NULL) + { + printf("Pb d'ouverture du fichier ActivitesJour.don\n"); + return -1; + } fscanf(flot, "%d%d%d%d%d%d%d", &NoCarte, &nom, &prenom, &age, &pointsCarte, &CarteActive, &nbActivitéesJour); + fscanf(jour, "%d%d", &Date, &nbActivitéesJour); while(!feof(flot)) { if(i == tmax) @@ -24,15 +29,26 @@ int Ouverture(int tNoCarte[],int tnom[], int tprenom[], int tage[], int tPointsC return -1; } tNoCarte[i] = NoCarte; - tnom[i] = nom; - tprenom[i] = prenom; tage[i] = age; tPointsCarte[i] = pointsCarte; tCarteActive[i] = CarteActive; - tNbActivitéesJour[i] = nbActivitéesJour; fscanf(flot, "%d%d%d%d%d%d%d", &NoCarte, &nom, &prenom, &age, &pointsCarte, &CarteActive, &nbActivitéesJour); i++; } + while(!feof(jour)) + { + if(j == tmax) + { + printf("Tableau plein\n"); + fclose(jour); + return -1; + } + Date[j] = Date; + tNbActivitesJour[j] = nbActivitesJour; + fscanf(jour, "%d%d", &Date, &nbActivitéesJour); + j++; + } + fclose(jour); fclose(flot); return i; }