|
|
|
@ -10,11 +10,18 @@
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include "deux.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Candidat* creerCandidat(void) {
|
|
|
|
|
Candidat* candidat = (Candidat*) malloc(sizeof(Candidat));
|
|
|
|
|
|
|
|
|
|
if(candidat == NULL) {
|
|
|
|
|
perror("malloc");
|
|
|
|
|
exit(errno);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//candidat->listeCandidatures = (ListeCandidatures) malloc(0);
|
|
|
|
|
|
|
|
|
|
return candidat;
|
|
|
|
@ -22,6 +29,12 @@ Candidat* creerCandidat(void) {
|
|
|
|
|
|
|
|
|
|
Candidature* creerCandidature(void) {
|
|
|
|
|
Candidature* candid = (Candidature*) malloc(sizeof(Candidature));
|
|
|
|
|
|
|
|
|
|
if(candid == NULL) {
|
|
|
|
|
perror("malloc");
|
|
|
|
|
exit(errno);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
candid->decision = 0;
|
|
|
|
|
candid->validation = 0;
|
|
|
|
|
return candid;
|
|
|
|
@ -47,6 +60,11 @@ void ajouterCandidature(Candidat* candidat, Candidature* candidature) {
|
|
|
|
|
void afficherListeCandidats(ListeCandidats liste, int nbCandidats) {
|
|
|
|
|
ListeCandidats liste2 = (ListeCandidats) malloc(nbCandidats*sizeof(Candidat*));
|
|
|
|
|
|
|
|
|
|
if(liste2 == NULL) {
|
|
|
|
|
perror("malloc");
|
|
|
|
|
exit(errno);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i=0; i<nbCandidats; i++) {
|
|
|
|
|
memcpy(&liste2[i], &liste[i], sizeof(Candidat*));
|
|
|
|
|
}
|
|
|
|
@ -127,6 +145,11 @@ ListeCandidats lireCandidats(int* nbCandidats) {
|
|
|
|
|
|
|
|
|
|
ListeCandidats liste = (ListeCandidats) malloc(*nbCandidats*sizeof(Candidat));
|
|
|
|
|
|
|
|
|
|
if(liste == NULL) {
|
|
|
|
|
perror("malloc");
|
|
|
|
|
exit(errno);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(int i=0; i<*nbCandidats; i++) {
|
|
|
|
|
Candidat* candidat = creerCandidat();
|
|
|
|
|
fscanf(fe, "%d\n%[^\n]\n%[^\n]\n%f\n%f\n%f\n%f\n%d",
|
|
|
|
@ -136,10 +159,22 @@ ListeCandidats lireCandidats(int* nbCandidats) {
|
|
|
|
|
&candidat->nbCandidatures);
|
|
|
|
|
|
|
|
|
|
ListeCandidatures listeCandidatures = (ListeCandidatures) malloc(candidat->nbCandidatures*sizeof(Candidature*));
|
|
|
|
|
|
|
|
|
|
if(listeCandidatures == NULL) {
|
|
|
|
|
perror("malloc");
|
|
|
|
|
exit(errno);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
candidat->listeCandidatures = listeCandidatures;
|
|
|
|
|
|
|
|
|
|
for(int j=0; j<candidat->nbCandidatures; j++) {
|
|
|
|
|
Candidature* candidature = (Candidature*) malloc(sizeof(Candidature));
|
|
|
|
|
|
|
|
|
|
if(candidature == NULL) {
|
|
|
|
|
perror("malloc");
|
|
|
|
|
exit(errno);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fscanf(fe, "\n%[^\n]\n%[^\n]\n%d%d",
|
|
|
|
|
candidature->ville, candidature->departement,
|
|
|
|
|
&candidature->decision, &candidature->validation);
|
|
|
|
|