almost done with part 2

master
lolax 2 years ago
parent ea18d64e4b
commit ce716d4bc5

@ -31,7 +31,6 @@ Choix lireC(FILE *fe)
fgets(c.dptmt, 26, fe);
c.dptmt[strlen(c.dptmt)-1]= '\0';
fscanf(fe, "%d %d%*c", &c.dec, &c.valid);
printf("J'ai bien été scanné\n");
return c;
}
@ -195,7 +194,6 @@ Listecand Chargementlistecandidat(FILE *fe, Listecand lC, int *nbC)// fonction d
for (cpt = Ca.nbchx; cpt >= 1; cpt--)
{
printf("je passe et je marche\n");
Maillonchx chx;
Choix c;
c = lireC(fe);//lire le maillon avec la fonction plus haut
@ -219,6 +217,7 @@ void testchgt(void)
if (fe == NULL){printf("pb ouv file"); return;}
lC = Chargementlistecandidat(fe, lC, &nbC);
AffListeCandidat(lC);
Save(lC, nbC);
}
@ -276,43 +275,40 @@ void test (void){
}
void Save(Listecand lC, int nbC)
{
FILE *fs;
fs=fopen("part2.don", "w");
if (fs == NULL){printf("pb ouv fichier part2.don\n");exit(-1);}
int cpt;
fprintf(fs, "%nbC\n", nbC);
saveC(lC, fs);
}
void saveC(Listecand lC, FILE *fs)
{
if (lC == NULL)return;
fprintf(fs, "%d\n", lC->cand.nEtu);
fprintf(fs, "%s\n", lC->cand.nom);
fprintf(fs, "%s\n", lC->cand.prenom);
fprintf(fs, "%.2f\t %.2f\t %.2f\t %.2f\n", lC->cand.moymat, lC->cand.moyfr, lC->cand.moyen, lC->cand.moyspe);
fprintf(fs, "%d\n", lC->cand.nbchx);
saveChx(lC->cand.lchx, fs);
saveC(lC->suivcand, fs);
}
void saveChx(Listechx lCh, FILE *fs)
{
if (lCh == NULL)return;
fprintf(fs, "%s\n", lCh->chx.ville);
fprintf(fs, "%s\n", lCh->chx.dptmt);
fprintf(fs, "%d\n", lCh->chx.dec);
fprintf(fs, "%d\n", lCh->chx.valid);
saveChx(lCh->suivchx, fs);
}
//####################################### FILES #################################################

@ -39,10 +39,6 @@ typedef struct {
}Candidat;
typedef struct Mailloncand{
Candidat cand;
struct Mailloncand * suivcand;
@ -50,23 +46,25 @@ typedef struct Mailloncand{
typedef Mailloncand * Listecand;
Choix lirechx (void);
Choix lireC(FILE *fe);
Candidat lireCandidat(void);
Candidat lireCa(FILE *fe);
Listechx InsertTC(Listechx list, Maillonchx m);
Listechx InsertC(Listechx list, Maillonchx m);
void AffC(Candidat c);
void AffCh(Choix c);
void AffListeCandidat (Listecand l);
void AffListChoix(Listechx l);
Listecand recherchenom (Listecand l, char *nom );
Listecand recherchenum (Listecand l, int num);
Listecand Chargementlistecandidat(FILE *fe, Listecand lC, int *nbC);
Listecand Insert(Listecand list, Candidat c);
Listecand InsertT(Listecand list, Candidat c);
void test (void);
Choix lirechx (void);//permet de lire un choix selon une entrée stdin
Choix lireC(FILE *fe);//ermet de lire un choix avec un FILe de type fichier.don
Candidat lireCandidat(void);//permet de lire un candidat avec le clavier
Candidat lireCa(FILE *fe);//permet de lire un candidat selon le fichier.don
Listechx InsertTC(Listechx list, Maillonchx m);//insertion en tête d'un maillon de type choix
Listechx InsertC(Listechx list, Maillonchx m);//insertion globale d'un maillon de type choix
void AffC(Candidat c);//affichage simple d'un candidat
void AffCh(Choix c);//affichage simple d'un choix
void AffListeCandidat (Listecand l);//affiche complet de la liste de candidats
void AffListChoix(Listechx l);//affichage complet de la liste de choix
Listecand recherchenom (Listecand l, char *nom );//recherche par un nom dans une liste de candidats
Listecand recherchenum (Listecand l, int num);//recherche par le numéro dans une liste de candidats
Listecand Chargementlistecandidat(FILE *fe, Listecand lC, int *nbC);//chargement du fichier dans une liste de candidats
Listecand Insert(Listecand list, Candidat c);//insertion en tête d'un maillon de type Candidat
Listecand InsertT(Listecand list, Candidat c);//insertion globale d'un maillon de type Candidat
void test (void);//fonction globale
void testchgt(void);
void affpartonsenpete(Listecand lC, int nbC);
void saveC(Listecand lC, FILE *fs);
void Save(Listecand lC, int nbC);
void saveChx(Listechx lCh, FILE *fs);

Loading…
Cancel
Save