From 32fab8aa1efd11f19f4f26dd05f0c9f5c81cc11b Mon Sep 17 00:00:00 2001 From: Jade VAN BRABANDT Date: Mon, 26 Dec 2022 18:13:16 +0100 Subject: [PATCH] Ajout de la fonction Load candidat --- src/partie2/saeP2.c | 62 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/src/partie2/saeP2.c b/src/partie2/saeP2.c index 6e8fc77..d839a6d 100644 --- a/src/partie2/saeP2.c +++ b/src/partie2/saeP2.c @@ -2,3 +2,65 @@ #include #include #include "saeP2.h" + + +candidat* LoadCandid(void) +{ +//J'ouvre le fichier + FILE* file; + if((file=fopen(candid.bin,"wb")==NULL) + { + errnum=errno; + perror("Erreur : "); + exit(1); + } +//Lire la première ligne pr savoir combien d'étudiant je vais lire + int nbcandid; + fread(&nbcandid,sizeof(int),1,file); + candidat Listecandidat[nbcandid]; +//Tant que j'ai des étudiants à lire : + for(int i=0;nbcandid>i;++i) + { +//Son numéro, Son nom, Son prenom, liste de note + int numcandid; + char surname[31]; + char name[31]; + float note[4]; + fread(&numcandid,sizeof(int),1,file); + fread(surname,sizeof(char)*31,1,file); + fread(name,sizeof(char)*31,1,file); + fread(note,sizeof(int)*4,1,file); +//Son nb de choix + int nbchoix; + fread(&nbchoix,sizeof(int),1,file); +//Tant que j'ai pas fait tout ces choix : + for(int y=0;y