05/11 Fonction de sauvegarde ajoutée pour les adhérents (à modifier avec toutes les futures informations disponibles)

master
Louis LABORIE 3 years ago
parent b26a6b20a2
commit 9d94955eab

@ -1,5 +1,6 @@
2
89
14
77
56
69
77
89

@ -166,7 +166,7 @@ void alimenterCarte (int tabAdherent[], int tabPoint[],int nb)
i = recherche(tabAdherent, num, nb, &trouve);
if (trouve == 1)
{
printf("Qu'elle formule :\n");
printf("Quelle formule :\n");
printf("A : 5€ -> 5 points\n");
printf("B : 10€ -> 12 point\n");
printf("C : 15€ -> 20 point\n");
@ -204,9 +204,18 @@ void alimenterCarte (int tabAdherent[], int tabPoint[],int nb)
int SauvegardeAdherent(int tabAdherent[], int tailleL) {
int i;
FILE* flot = fopen("adherent.txt","w");
if (flot == NULL) {
printf("Erreur d'ouverture du fichier !\n");
return -1;
}
for (i = 0 ; i < tailleL ; i++) {
fprintf(flot,"%d\n",tabAdherent[i]);
}
return 0;
}

@ -24,4 +24,7 @@ void affichageInfo(int tabNumCarte[], int tabPoint[], int carte[], int jour[], i
void affichageTous(int tabNumCarte[], int tabPoint[], int carte[], int jour[], int mois[], int annee[],int taille);
void affichageTest(int tabAdhe[], int nb);
void affichageTest(int tabAdhe[], int nb);
int SauvegardeAdherent(int tabAdherent[], int tailleL);

@ -3,12 +3,31 @@
int main(void) {
int tab[50], tailleL;
int tab[50], tailleL, codeSauv, coderetour=-1;
tailleL=chargementAdherent(tab,50);
affichageTest(tab,tailleL);
tailleL=ajouter(tab,tailleL,69,50);
affichageTest(tab,tailleL);
tailleL=suppression(tab,tailleL,69);
affichageTest(tab,tailleL);
// tailleL=suppression(tab,tailleL,69);
// affichageTest(tab,tailleL);
printf("Sauvegarder ? (1 : Oui, 2 : Non)\n");
scanf("%d",&codeSauv);
if (codeSauv == 1) {
while(coderetour == -1) {
coderetour = SauvegardeAdherent(tab,tailleL);
if (coderetour == 0) {
printf("Sauvegarde réussie !\n");
break;
}
else {
printf("Sauvegarde échouée\n");
printf("Réessayer ?(1 : Oui, 2 : Non\n");
scanf("%d",&codeSauv);
if (codeSauv == 2) break;
}
}
}
return 0;
}
Loading…
Cancel
Save