|
|
@ -2,3 +2,65 @@
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include "saeP2.h"
|
|
|
|
#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<nbchoix;++y)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//Je lis La ville, le département, la décision du dep, la validation du candidat
|
|
|
|
|
|
|
|
char ville[31];
|
|
|
|
|
|
|
|
char dep[31];
|
|
|
|
|
|
|
|
int ddep;
|
|
|
|
|
|
|
|
int vcand;
|
|
|
|
|
|
|
|
fread(ville,sizeof(char)*31,1,file);
|
|
|
|
|
|
|
|
fread(dep,sizeof(char)*31,1,file);
|
|
|
|
|
|
|
|
fread(ddep,sizeof(int),1,file);
|
|
|
|
|
|
|
|
fread(vcand,sizeof(int),1,file);
|
|
|
|
|
|
|
|
voeu voeu_ajout;
|
|
|
|
|
|
|
|
voeu_ajout.ville=ville;
|
|
|
|
|
|
|
|
voeu_ajout.dep=dep;
|
|
|
|
|
|
|
|
voeu_ajout.ddep=ddep;
|
|
|
|
|
|
|
|
voeu_ajout.vcand=vcand;
|
|
|
|
|
|
|
|
voeu ListeVoeu_ajout[100];
|
|
|
|
|
|
|
|
ListeVoeu_ajout[i]=voeu_ajout;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Candidat_ajout.numcandid=numcandid;
|
|
|
|
|
|
|
|
Candidat_ajout.surname=surname;
|
|
|
|
|
|
|
|
Candidat_ajout.name=name;
|
|
|
|
|
|
|
|
Candidat_ajout.note=note;
|
|
|
|
|
|
|
|
Candidat_ajout.ListeVoeu=ListeVoeu_ajout;
|
|
|
|
|
|
|
|
Listecandidat[i]=Candidat_ajout;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//Je sors en disant que le load est sucessful
|
|
|
|
|
|
|
|
printf("Chargement réussie.")
|
|
|
|
|
|
|
|
return Listecandidat;
|
|
|
|
|
|
|
|
}
|