You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
3.3 KiB

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include "saeP2.h"
#include <string.h>
candidat* LoadCandid(void)
{
//J'ouvre le fichier
FILE* file;
if((file=fopen("candid.bin","rb"))==NULL)
{
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* Tabcandidat=(candidat*) malloc (sizeof(candidat)*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`
candidat Candidat_ajout;
fread(&Candidat_ajout.numcandid,sizeof(int),1,file);
fread(Candidat_ajout.surname,sizeof(char)*31,1,file);
fread(Candidat_ajout.name,sizeof(char)*31,1,file);
fread(Candidat_ajout.note,sizeof(float)*4,1,file);
//Son nb de choix
fread(&Candidat_ajout.nbchoix,sizeof(int),1,file);
//Tant que j'ai pas fait tout ces choix :
for(int y=0;y<Candidat_ajout.nbchoix;++y)
{
//Je lis La ville, le département, la décision du dep, la validation du candidat
voeu* voeu_ajout=(voeu*)malloc(sizeof(voeu));
fread(voeu_ajout->ville,sizeof(char)*31,1,file);
fread(voeu_ajout->dep,sizeof(char)*31,1,file);
fread(&voeu_ajout->ddep,sizeof(int),1,file);
fread(&voeu_ajout->vcand,sizeof(int),1,file);
Candidat_ajout.TabVoeu[i]=voeu_ajout;
}
Tabcandidat[i]=Candidat_ajout;
}
//Je sors en disant que le load est sucessful
printf("Chargement réussie.");
return Tabcandidat;
}
void RechercheCandidat(int ID, int nbcandidat, int tmax,candidat *tcandidat)
{
for(int i=0;i<nbcandidat;++i)
{
if(i==nbcandidat)
{
printf("Candidat Trouvé :\n\
Numéro : %d\n\
Nom : %s\n\
Prenom : %s\n\
Note de mathématique : %f\n\
Note de français : %f\n\
Note d'anglais : %f\n\
Note de spécialité : %f\n\
Nombre de voeu : %d\n\
Voeu :\n",tcandidat[i].numcandid,tcandidat[i].surname,tcandidat[i].name,\
tcandidat[i].note[0],tcandidat[i].note[1],tcandidat[i].note[2],\
tcandidat[i].note[3],tcandidat[i].nbchoix);
for(int y=0;y<tcandidat[i].nbchoix;++y)
{
printf("Ville : %s\n\
Departement : %s\n\
Décision département : ",tcandidat[i].TabVoeu[y]->ville,tcandidat[i].TabVoeu[y]->dep);
if(tcandidat[i].TabVoeu[y]->ddep==0) printf("Dossier non traité\n");
else {
if(tcandidat[i].TabVoeu[y]->ddep==1) printf("Admis\n");
else {
if (tcandidat[i].TabVoeu[y]->ddep==2) printf("Liste d'attente\n");
else printf("Refusé\n");
}
}
printf("Décision du candidat : ");
if(tcandidat[i].TabVoeu[y]->vcand==0) printf("Décision non rendu\n");
else {
if(tcandidat[i].TabVoeu[y]->vcand==1) printf("Accepté\n");
else printf("Refusé");
}
}
return;
}
}
printf("Candidat non trouvé");
return;
}
//void gestionPhaseCandidatures(); A FAIRE.