Ajout de la fonction saveIUT() permettant de sauvegarder les IUTs enregistrés en mémoire.

master
Yann CHAMPEAU 3 years ago
commit 72c83e78dd

2
.gitignore vendored

@ -36,6 +36,7 @@
*.i*86 *.i*86
*.x86_64 *.x86_64
*.hex *.hex
SAE
# Debug files # Debug files
*.dSYM/ *.dSYM/
@ -61,6 +62,7 @@ dkms.conf
# Icon must end with two \r # Icon must end with two \r
Icon Icon
# Thumbnails # Thumbnails
._* ._*

@ -0,0 +1 @@
src/DataBase/Etudiants.bin

@ -0,0 +1,5 @@
A
6
Yann

@ -1,9 +1,14 @@
PHONY : clean doc all .PHONY: clean doc all
all : prog
all : prog EXE
prog : prog :
make -C src all make -C src all
EXE :
rm -f SAE
gcc -g -o SAE src/saeMain.o src/annexe/saeAnnexe.o src/partie1/saeP1.o src/partie2/saeP2.o src/partie3/saeP3.o src/partie4/saeP4.o
doc : doc :
make -C src doc make -C src doc

@ -1,16 +1,13 @@
all : SAE .PHONY : all doc clean lib
.PHONY : all doc clean all : saeMain.o lib
lib : annexe/saeAnnexe.o partie1/saeP1.o partie2/saeP2.o partie3/saeP3.o partie4/saeP4.o lib :
make -C annexe all make -C annexe
make -C partie1 all make -C partie1
make -C partie2 all make -C partie2
make -C partie3 all make -C partie3
make -C partie4 all make -C partie4
SAE : saeMain.o lib
gcc -o ../SAE saeMain.o annexe/saeAnnexe.o partie1/saeP1.o partie2/saeP2.o partie3/saeP3.o partie4/saeP4.o
saeMain.o : saeMain.c saeMain.o : saeMain.c
gcc -Wall -c saeMain.c gcc -Wall -c saeMain.c

@ -1,3 +1,7 @@
CC = gcc
CCOPTS = -Wall
all : saeAnnexe.o all : saeAnnexe.o
saeAnnexe.o : saeAnnexe.c saeAnnexe.h saeAnnexe.o : saeAnnexe.c saeAnnexe.h

@ -15,6 +15,7 @@ void menu(void){
printf("C : Consultation.\n"); printf("C : Consultation.\n");
printf("A : Administrateur.\n"); printf("A : Administrateur.\n");
printf("S : Sauvegarder.\n\n"); printf("S : Sauvegarder.\n\n");
printf("Q : Quitter.\n\n");
printf("#--------------------------------------------------------------------#\n\n"); printf("#--------------------------------------------------------------------#\n\n");
printf("Choisissez votre session : "); printf("Choisissez votre session : ");
} }
@ -59,6 +60,7 @@ int loadIUT(VilleIUT** tiut){
return tlogi; return tlogi;
} }
<<<<<<< HEAD
void saveIUT(VilleIUT** tiut, int tlogi){ void saveIUT(VilleIUT** tiut, int tlogi){
FILE* f=fopen("Etudiants.bin","rb"); FILE* f=fopen("Etudiants.bin","rb");
if(f==NULL){ if(f==NULL){
@ -85,12 +87,14 @@ void saveIUT(VilleIUT** tiut, int tlogi){
} }
int rechercheTabPtVilleIUT(VilleIUT* tab[],int lTab,char* mot){ int rechercheTabPtVilleIUT(VilleIUT* tab[],int lTab,char* mot){
=======
int rechercheIUT(VilleIUT* tab[],int lTab,char mot[]){
>>>>>>> d1df1ce5e50feb147850be94e120a32207905272
if(!lTab){ if(!lTab){
fprintf(stderr,"Erreur, Pas d'éléments dans le tableau !");
return -1; return -1;
} }
for(int i=0; i<lTab;i++){ for(int i=0; i<lTab;i++){
if(tab[i]->Ville==mot) return i; if(!strcmp(tab[i]->Ville,mot)) return i;
} }
return -1; return -1;
} }

@ -33,7 +33,7 @@ int loadIUT(VilleIUT** tiut); //
// //
void saveIUT(VilleIUT** tiut, int tlogi); // void saveIUT(VilleIUT** tiut, int tlogi); //
// //
int rechercheTabPtVilleIUT(VilleIUT* tab[],int lTab,char* mot); // int rechercheIUT(VilleIUT* tab[],int lTab,char mot[]); //
// //
// //
// //

@ -1,7 +1,7 @@
all : saeP1.o all : saeP1.o
saeP1.o : saeP1.c saeP1.h saeP1.o : saeP1.c saeP1.h
gcc -Wall -c saeP1.c gcc -Wall -Werror -Wextra -g -c saeP1.c
doc : saeP1.h doc : saeP1.h
doxygen doxygen

@ -8,9 +8,11 @@
//Partie Consultant. //Partie Consultant.
void MenuUser(VilleIUT* lvIUT[],int tlogi) void menuUser(VilleIUT* lvIUT[],int tlogi)
{ {
int intUserEntry=0; int quit=0;
while(!quit)
{
printf("#--------------------------------------------------------------------#\n"); printf("#--------------------------------------------------------------------#\n");
printf("| |\n"); printf("| |\n");
printf("| SAE S1.02 |\n"); printf("| SAE S1.02 |\n");
@ -21,33 +23,60 @@ void MenuUser(VilleIUT* lvIUT[],int tlogi)
printf("2 : Afficher tout les départements de chaques IUT\n"); printf("2 : Afficher tout les départements de chaques IUT\n");
printf("3 : Afficher le nombre de place en première année d'un IUT précis avec un département précis\n"); printf("3 : Afficher le nombre de place en première année d'un IUT précis avec un département précis\n");
printf("4 : Rechercher les IUTs possèdant un département précis.\n"); printf("4 : Rechercher les IUTs possèdant un département précis.\n");
/*if(CandidOpen)
{
printf("5 : Candidater");
}*/
printf("9 : Revenir à l'écran de sélection du profil.\n\n"); printf("9 : Revenir à l'écran de sélection du profil.\n\n");
printf("#--------------------------------------------------------------------#\n\n"); printf("#--------------------------------------------------------------------#\n\n");
while(intUserEntry!=9)
{
printf("Choisissez l'action que vous voulez exécuter : "); printf("Choisissez l'action que vous voulez exécuter : ");
if (!(scanf("%d",intUserEntry)))printf("Entrée innexacte. Veuillez réessayer"); int act;
if (intUserEntry==1) SearchCityWithIUT(lvIUT,tlogi); scanf("%d",&act);
if (intUserEntry==2) DepEachIUT(lvIUT,tlogi); switch(act){
if (intUserEntry==3) SearchPlaceFromDepInIUT(lvIUT,tlogi); case 1:
if (intUserEntry==4) SearchIUTFromDep(lvIUT,tlogi); SearchCityWithIUT(lvIUT,tlogi);
if (intUserEntry==9) printf("Sortie en cours.\n"); reset();
else printf("Entrée innexacte. Veuillez réessayer"); break;
case 2:
DepEachIUT(lvIUT,tlogi);
reset();
break;
case 3:
SearchPlaceFromDepInIUT(lvIUT,tlogi);
reset();
break;
case 4:
SearchIUTFromDep(lvIUT,tlogi);
reset();
break;
case 5:
//candidater(......);
reset();
break;
case 9:
quit=1;
reset();
}
} }
} }
void SearchCityWithIUT(VilleIUT* lvIUT[], int tlogi) void SearchCityWithIUT(VilleIUT* lvIUT[], int tlogi)
{ {
for (int i=0;i<tlogi;++i) printf("%s",lvIUT[i]->Ville); for (int i=0;i<tlogi;++i) printf("\n - %s",lvIUT[i]->Ville);
} }
void DepEachIUT(VilleIUT* lvIUT[], int tlogi) void DepEachIUT(VilleIUT* lvIUT[], int tlogi)
{ {
for (int i=0;i<tlogi;++i) for (int i=0;i<tlogi;++i)
{ {
printf("%s :",lvIUT[i]->Ville); printf("\n - %s :",lvIUT[i]->Ville);
MaillonDep* MaillonAct=lvIUT[i]->ldept; MaillonDep* MaillonAct=lvIUT[i]->ldept;
while (MaillonAct!=NULL) printf("\t-%s\n",MaillonAct->departement); while (MaillonAct!=NULL)
{
printf("\t-%s\n",MaillonAct->departement);
MaillonAct=MaillonAct->suivant;
}
} }
} }
@ -56,57 +85,63 @@ void SearchPlaceFromDepInIUT(VilleIUT* lvIUT[],int tlogi)
char sVille[31]; char sVille[31];
char sDep[31]; char sDep[31];
int boolF=0, i; int boolF=0, i;
printf("Entrez le nom de la ville contenant le département recherché :\n"); printf("\nEntrez le nom de la ville contenant le département recherché :\n");
scanf("%s",sVille); scanf("%s",sVille);
printf("Département y étant disponible :\n");
for (i=0;i<tlogi;++i) for (i=0;i<tlogi;++i)
{ {
if (lvIUT[i]->Ville==sVille) if (!strcmp(lvIUT[i]->Ville,sVille))
{ {
printf("\nDépartement y étant disponible :\n");
MaillonDep* MaillonAct=lvIUT[i]->ldept; MaillonDep* MaillonAct=lvIUT[i]->ldept;
while (MaillonAct!=NULL) printf("%s",MaillonAct->departement); while (MaillonAct!=NULL)
boolF=1; {
printf("\t-%s\n",MaillonAct->departement);
MaillonAct=MaillonAct->suivant; MaillonAct=MaillonAct->suivant;
}
boolF=1;
break; break;
} }
} }
if (!boolF) if (!boolF)
{ {
printf("La ville n'est pas dans la liste.\nMerci de vérifier l'orthographe.\n"); printf("\nLa ville n'est pas dans la liste.\nMerci de vérifier l'orthographe.\n");
return; return;
} }
printf("Entrez le nom du département dont vous souhaitez connaitre le nombre de place\n"); printf("\nEntrez le nom du département dont vous souhaitez connaitre le nombre de place\n");
scanf("%s",sDep); scanf("%s",sDep);
MaillonDep* MaillonAct=lvIUT[i]->ldept; MaillonDep* MaillonAct=lvIUT[i]->ldept;
while (MaillonAct!=NULL) while (MaillonAct!=NULL)
{ {
if(MaillonAct->departement==sDep) if(!strcmp(MaillonAct->departement,sDep))
{ {
printf("Nombre de place : %d\n",MaillonAct->nbp); printf("\nNombre de place : %d\n",MaillonAct->nbp);
return; return;
} }
MaillonAct=MaillonAct->suivant; MaillonAct=MaillonAct->suivant;
} }
printf("Le département n'est pas dans la liste.\nMerci de vérifier l'orthographe.\n"); printf("\nLe département n'est pas dans la liste.\nMerci de vérifier l'orthographe.\n");
} }
void SearchIUTFromDep(VilleIUT* lvIUT[],int tlogi) void SearchIUTFromDep(VilleIUT* lvIUT[],int tlogi)
{ {
char sDep[31]; char sDep[31];
printf("Merci de renseignez le département dont vous cherchez les IUTs :\n"); printf("\nMerci de renseignez le département dont vous cherchez les IUTs :\n");
scanf("%s",sDep); scanf("%s",sDep);
printf("\nVoici la liste des IUTs contenant le département mentionné :\n\n");
for (int i=0;i<tlogi;++i) for (int i=0;i<tlogi;++i)
{ {
MaillonDep* MaillonAct=lvIUT[i]->ldept; MaillonDep* MaillonAct=lvIUT[i]->ldept;
if(MaillonAct->departement==sDep) printf("%s",lvIUT[i]->Ville); while(MaillonAct!=NULL){
if(!strcmp(MaillonAct->departement,sDep)) printf("\t-%s\n",lvIUT[i]->Ville);
MaillonAct=MaillonAct->suivant;
}
} }
} }
//Partie Administrateur. //Partie Administrateur.
void menuAdmin(VilleIUT* tiut[],int tlogi){ void menuAdmin(VilleIUT* tiut[],int *tlogi){
int quit=0; int quit=0;
while(!quit){ while(!quit){
printf("#--------------------------------------------------------------------#\n"); printf("#--------------------------------------------------------------------#\n");
@ -120,6 +155,7 @@ void menuAdmin(VilleIUT* tiut[],int tlogi){
printf("3 : Supprimer un département dun IUT.\n"); printf("3 : Supprimer un département dun IUT.\n");
printf("4 : Lancer et arrêter la phase de candidature.\n"); printf("4 : Lancer et arrêter la phase de candidature.\n");
printf("5 : Modifier le nom d'un responsable de département.\n"); printf("5 : Modifier le nom d'un responsable de département.\n");
printf("6 : Créer un IUT.\n");
printf("9 : Revenir à l'écran de sélection du profil.\n\n"); printf("9 : Revenir à l'écran de sélection du profil.\n\n");
printf("#--------------------------------------------------------------------#\n\n"); printf("#--------------------------------------------------------------------#\n\n");
printf("Choisissez l'action que vous voulez exécuter : "); printf("Choisissez l'action que vous voulez exécuter : ");
@ -127,15 +163,15 @@ void menuAdmin(VilleIUT* tiut[],int tlogi){
scanf("%d",&act); scanf("%d",&act);
switch(act){ switch(act){
case 1: case 1:
modifPlaces(tiut,tlogi); modifPlaces(tiut,*tlogi);
reset(); reset();
break; break;
case 2: case 2:
creerDep(tiut,tlogi); creerDep(tiut,*tlogi);
reset(); reset();
break; break;
case 3: case 3:
supprimerDep(tiut,tlogi); supprimerDep(tiut,*tlogi);
reset(); reset();
break; break;
case 4: case 4:
@ -143,7 +179,11 @@ void menuAdmin(VilleIUT* tiut[],int tlogi){
reset(); reset();
break; break;
case 5: case 5:
modifNomResponsable(tiut,tlogi); modifNomResponsable(tiut,*tlogi);
reset();
break;
case 6:
creerIUT(tiut,tlogi);
reset(); reset();
break; break;
case 9: case 9:
@ -154,20 +194,20 @@ void menuAdmin(VilleIUT* tiut[],int tlogi){
} }
void modifPlaces(VilleIUT* tiut[],int tlogi){ void modifPlaces(VilleIUT* tiut[],int tlogi){
printf("\nEntrez la ville correspondant à l'IUT à modifier (Q pour abandonner):"); printf("\nEntrez la ville correspondant à l'IUT à modifier (Q pour abandonner): ");
char ville[31]; char ville[31];
scanf("%*c%s",&ville); scanf("%s",ville);
if(ville[0]=='Q' && ville[1]=='\0') return; if(ville[0]=='Q' && ville[1]=='\0') return;
int noVille=rechercheTabPtVilleIUT(tiut,tlogi,ville); int noVille=rechercheIUT(tiut,tlogi,ville);
if(noVille<=0){ if(noVille<0){
fprintf(stderr,"\nVille non existante !\n"); fprintf(stderr,"\nVille non existante !\n");
return; return;
} }
VilleIUT* v=tiut[noVille]; VilleIUT* v=tiut[noVille];
printf("\n\nEntrez le département à modifier:"); printf("\n\nEntrez le département à modifier :");
char dep[31]; char dep[31];
scanf("%*c%s",&dep); scanf("%s",dep);
if(!existeDep(tiut->ldept,dep)){ if(!existeDep(v->ldept,dep)){
fprintf(stderr,"\nDépartement non existant !\n"); fprintf(stderr,"\nDépartement non existant !\n");
return; return;
} }
@ -182,17 +222,27 @@ void modifPlaces(VilleIUT* tiut[],int tlogi){
} }
void creerDep(VilleIUT* tiut[],int tlogi){ void creerDep(VilleIUT* tiut[],int tlogi){
printf("\nEntrez la ville correspondant à l'IUT à modifier (Q pour abandonner):"); printf("\nEntrez la ville correspondant à l'IUT à modifier (Q pour abandonner): ");
char ville[31]; char ville[31];
scanf("%*c%s",&ville); scanf("%s",ville);
if(ville[0]=='Q' && ville[1]=='\0') return; if(ville[0]=='Q' && ville[1]=='\0') return;
int noVille=rechercheTabPtVilleIUT(tiut,tlogi,ville); int noVille=rechercheIUT(tiut,tlogi,ville);
if(noVille<=0){ if(noVille<0){
fprintf(stderr,"\nVille non existante !\n"); fprintf(stderr,"\nVille non existante !\n");
return; return;
} }
VilleIUT* v=tiut[noVille]; VilleIUT* v=tiut[noVille];
int ck=0;
if(v->ldept==NULL){
ck=1;
v->ldept=(MaillonDep*)malloc(sizeof(MaillonDep));
if(v->ldept==NULL){
perror("malloc");
exit(errno);
}
}
MaillonDep* m=v->ldept; MaillonDep* m=v->ldept;
if(!ck){
while(m->suivant!=NULL) m=m->suivant; while(m->suivant!=NULL) m=m->suivant;
m->suivant=(MaillonDep*)malloc(sizeof(MaillonDep)); m->suivant=(MaillonDep*)malloc(sizeof(MaillonDep));
if(m->suivant==NULL){ if(m->suivant==NULL){
@ -200,35 +250,33 @@ void creerDep(VilleIUT* tiut[],int tlogi){
exit(errno); exit(errno);
} }
m=m->suivant; m=m->suivant;
printf("\n\nEntrez le nom du département à créer :"); }
char dep[31]; printf("\n\nEntrez le nom du département à créer : ");
scanf("%*c%s",&dep); scanf("%*c%s",m->departement);
strcpy(m->departement,dep); printf("\n\nEntrez le nombre de places disponibles dans le département : ");
printf("\n\nEntrez le nombre de places disponibles dans le département :");
scanf("%d",&m->nbp); scanf("%d",&m->nbp);
printf("\n\nEntrez le nom du responsable de département :"); printf("\n\nEntrez le nom du responsable de département : \n");
char resp[51]; scanf("%*c");
scanf("%*c%s",&resp); fgets(m->resp, 51, stdin);
strcpy(m->resp,resp); printf("\n\nLe département %s a bien été ajouté à l'IUT de %s.\n",m->departement,ville);
printf("\n\nLe département %s a bien été ajouté à l'IUT de %s.\n",dep,ville);
return; return;
} }
void supprimerDep(VilleIUT* tiut[],int tlogi){ void supprimerDep(VilleIUT* tiut[],int tlogi){
printf("\nEntrez la ville correspondant à l'IUT à modifier (Q pour abandonner):"); printf("\nEntrez la ville correspondant à l'IUT à modifier (Q pour abandonner): ");
char ville[31]; char ville[31];
scanf("%*c%s",&ville); scanf("%s",ville);
if(ville[0]=='Q' && ville[1]=='\0') return; if(ville[0]=='Q' && ville[1]=='\0') return;
int noVille=rechercheTabPtVilleIUT(tiut,tlogi,ville); int noVille=rechercheIUT(tiut,tlogi,ville);
if(noVille<=0){ if(noVille<0){
fprintf(stderr,"\nVille non existante !\n"); fprintf(stderr,"\nVille non existante !\n");
return; return;
} }
VilleIUT* v=tiut[noVille]; VilleIUT* v=tiut[noVille];
printf("\n\nEntrez le département à supprimer:"); printf("\n\nEntrez le département à supprimer:");
char dep[31]; char dep[31];
scanf("%*c%s",&dep); scanf("%s",dep);
if(!existeDep(tiut->ldept,dep)){ if(!existeDep(v->ldept,dep)){
fprintf(stderr,"\nDépartement non existant !\n"); fprintf(stderr,"\nDépartement non existant !\n");
return; return;
} }
@ -236,6 +284,7 @@ void supprimerDep(VilleIUT* tiut[],int tlogi){
if(m->departement==dep){ if(m->departement==dep){
printf("\n\nVoulez-vous supprimer le département %s de la ville de %s ? (Y pour continuer)\n\n",m->departement,v->Ville); printf("\n\nVoulez-vous supprimer le département %s de la ville de %s ? (Y pour continuer)\n\n",m->departement,v->Ville);
char choix; char choix;
scanf("%*c%c",&choix);
if(choix!='Y') return; if(choix!='Y') return;
v->ldept=m->suivant; v->ldept=m->suivant;
free(m); free(m);
@ -244,6 +293,7 @@ void supprimerDep(VilleIUT* tiut[],int tlogi){
while(m->suivant->departement!=dep) m=m->suivant; while(m->suivant->departement!=dep) m=m->suivant;
printf("\n\nVoulez-vous supprimer le département %s de la ville de %s ? (Y pour continuer)\n\n",m->suivant->departement,v->Ville); printf("\n\nVoulez-vous supprimer le département %s de la ville de %s ? (Y pour continuer)\n\n",m->suivant->departement,v->Ville);
char choix; char choix;
scanf("%*c%c",&choix);
if(choix!='Y') return; if(choix!='Y') return;
MaillonDep* temp; MaillonDep* temp;
temp=m->suivant; temp=m->suivant;
@ -255,20 +305,20 @@ void supprimerDep(VilleIUT* tiut[],int tlogi){
} }
void modifNomResponsable(VilleIUT* tiut[],int tlogi){ void modifNomResponsable(VilleIUT* tiut[],int tlogi){
printf("\nEntrez la ville correspondant à l'IUT à modifier (Q pour abandonner):"); printf("\nEntrez la ville correspondant à l'IUT à modifier (Q pour abandonner): ");
char ville[31]; char ville[31];
scanf("%*c%s",&ville); scanf("%s",ville);
if(ville[0]=='Q' && ville[1]=='\0') return; if(ville[0]=='Q' && ville[1]=='\0') return;
int noVille=rechercheTabPtVilleIUT(tiut,tlogi,ville); int noVille=rechercheIUT(tiut,tlogi,ville);
if(noVille<=0){ if(noVille<0){
fprintf(stderr,"\nVille non existante !\n"); fprintf(stderr,"\nVille non existante !\n");
return; return;
} }
VilleIUT* v=tiut[noVille]; VilleIUT* v=tiut[noVille];
printf("\n\nEntrez le département à modifier:"); printf("\n\nEntrez le département à modifier:");
char dep[31]; char dep[31];
scanf("%*c%s",&dep); scanf("%s",dep);
if(!existeDep(tiut->ldept,dep)){ if(!existeDep(v->ldept,dep)){
fprintf(stderr,"\nDépartement non existant !\n"); fprintf(stderr,"\nDépartement non existant !\n");
return; return;
} }
@ -276,8 +326,31 @@ void modifNomResponsable(VilleIUT* tiut[],int tlogi){
while(m->departement!=dep) m=m->suivant; while(m->departement!=dep) m=m->suivant;
printf("\n\nLe responsable du département %s de l'IUT de la ville de %s est actuellement %s. Quel est le nom du nouveau responsable ?\n\n",m->departement,v->Ville,m->resp); printf("\n\nLe responsable du département %s de l'IUT de la ville de %s est actuellement %s. Quel est le nom du nouveau responsable ?\n\n",m->departement,v->Ville,m->resp);
char nom[51]; char nom[51];
scanf("%d",&nom); scanf("%s",nom);
strcpy(m->resp,nom); strcpy(m->resp,nom);
printf("\n\nLe nom du responsable du département %s de l'IUT de %s a bien été changé pour %s.\n",dep,ville,nom); printf("\n\nLe nom du responsable du département %s de l'IUT de %s a bien été changé pour %s.\n",dep,ville,nom);
return; return;
} }
void creerIUT(VilleIUT* tiut[],int* tlogi){
printf("\nEntrez le nom de la ville correspondant à l'IUT à ajouter (Q pour abandonner): ");
char ville[31];
scanf("%*c%s",ville);
if(ville[0]=='Q' && ville[1]=='\0') return;
int noVille=rechercheIUT(tiut,*tlogi,ville);
if(noVille>=0){
fprintf(stderr,"\nVille déjà existante !\n");
return;
}
VilleIUT* v=(VilleIUT*)malloc(sizeof(VilleIUT));
if(v==NULL){
perror("malloc");
exit(errno);
}
strcpy(v->Ville,ville);
v->ldept=NULL;
tiut[*tlogi]=v;
*tlogi=*tlogi+1;
printf("\n\nL'IUT de %s a bien été ajouté.\n",ville);
return;
}

@ -28,7 +28,7 @@ void SearchIUTFromDep(VilleIUT* lvIUT[],int tlogi);
//Admin //Admin
void menuAdmin(VilleIUT* tiut[],int tlogi); void menuAdmin(VilleIUT* tiut[],int* tlogi);
void modifPlaces(VilleIUT* tiut[],int tlogi); void modifPlaces(VilleIUT* tiut[],int tlogi);
@ -37,3 +37,5 @@ void creerDep(VilleIUT* tiut[],int tlogi);
void supprimerDep(VilleIUT* tiut[],int tlogi); void supprimerDep(VilleIUT* tiut[],int tlogi);
void modifNomResponsable(VilleIUT* tiut[],int tlogi); void modifNomResponsable(VilleIUT* tiut[],int tlogi);
void creerIUT(VilleIUT* tiut[],int* tlogi);

@ -2,13 +2,15 @@
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
#include "saeP2.h" #include "saeP2.h"
#include <string.h>
#include "../annexe/saeAnnexe.h"
#include "../partie1/saeP1.h"
candidat* LoadCandid(void) candidat* LoadCandid(void)
{ {
//J'ouvre le fichier //J'ouvre le fichier
FILE* file; FILE* file;
if((file=fopen(candid.bin,"wb")==NULL) if((file=fopen("candid.bin","rb"))==NULL)
{ {
perror("Erreur : "); perror("Erreur : ");
exit(1); exit(1);
@ -16,98 +18,173 @@ candidat* LoadCandid(void)
//Lire la première ligne pr savoir combien d'étudiant je vais lire //Lire la première ligne pr savoir combien d'étudiant je vais lire
int nbcandid; int nbcandid;
fread(&nbcandid,sizeof(int),1,file); fread(&nbcandid,sizeof(int),1,file);
candidat Listecandidat[nbcandid]; candidat* Tabcandidat=(candidat*) malloc (sizeof(candidat)*nbcandid);
//Tant que j'ai des étudiants à lire : //Tant que j'ai des étudiants à lire :
for(int i=0;nbcandid>i;++i) for(int i=0;nbcandid>i;++i)
{ {
//Son numéro, Son nom, Son prenom, liste de note //Son numéro, Son nom, Son prenom, liste de note`
int numcandid; candidat Candidat_ajout;
char surname[31]; fread(&Candidat_ajout.numcandid,sizeof(int),1,file);
char name[31]; fread(Candidat_ajout.surname,sizeof(char)*31,1,file);
float note[4]; fread(Candidat_ajout.name,sizeof(char)*31,1,file);
fread(&numcandid,sizeof(int),1,file); fread(Candidat_ajout.note,sizeof(float)*4,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 //Son nb de choix
int nbchoix; fread(&Candidat_ajout.nbchoix,sizeof(int),1,file);
fread(&nbchoix,sizeof(int),1,file);
//Tant que j'ai pas fait tout ces choix : //Tant que j'ai pas fait tout ces choix :
for(int y=0;y<nbchoix;++y) 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 //Je lis La ville, le département, la décision du dep, la validation du candidat
char ville[31]; voeu* voeu_ajout=(voeu*)malloc(sizeof(voeu));
char dep[31]; fread(voeu_ajout->ville,sizeof(char)*31,1,file);
int ddep; fread(voeu_ajout->dep,sizeof(char)*31,1,file);
int vcand; fread(&voeu_ajout->ddep,sizeof(int),1,file);
fread(ville,sizeof(char)*31,1,file); fread(&voeu_ajout->vcand,sizeof(int),1,file);
fread(dep,sizeof(char)*31,1,file); Candidat_ajout.TabVoeu[i]=voeu_ajout;
fread(ddep,sizeof(int),1,file); }
fread(vcand,sizeof(int),1,file); Tabcandidat[i]=Candidat_ajout;
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 //Je sors en disant que le load est sucessful
printf("Chargement réussie.") printf("Chargement réussie.");
return Listecandidat; return Tabcandidat;
} }
void RechercheCandidat(int ID, int nbcandidat, int tmax,candidat *tcand)
void SaveCandid(int nbcandidat,candidat *tcandidat)
{
//J'ouvre le fichier
FILE* file;
if((file=fopen("candid.bin","wb"))==NULL)
{
perror("Erreur : ");
exit(1);
}
//J'écris le nombre d'étudiant que je rentres
fwrite(&nbcandidat,sizeof(int),1,file);
//J'écris tout mes étudiants
fwrite(tcandidat,sizeof(candidat),nbcandidat,file);
printf("Sauvegarde réussit");
}
void RechercheCandidat(int ID, int nbcandidat,candidat *tcandidat)
{ {
for(int i=0;i<nbcandidat;++i) for(int i=0;i<nbcandidat;++i)
{ {
if(i==nbcandidat) if(i==nbcandidat)
{ {
printf("Candidat Trouvé :\n printf("Candidat Trouvé :\n\
Numéro : %d\n Numéro : %d\n\
Nom : %s\n Nom : %s\n\
Prenom : %s\n Prenom : %s\n\
Note de mathématique : %f\n Note de mathématique : %f\n\
Note de français : %f\n Note de français : %f\n\
Note d'anglais : %f\n Note d'anglais : %f\n\
Note de spécialité : %f\n Note de spécialité : %f\n\
Nombre de candidature : %d\n Nombre de voeu : %d\n\
Nombre de voeu : %d\n Voeu :\n",tcandidat[i].numcandid,tcandidat[i].surname,tcandidat[i].name,\
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[0],tcandidat[i].note[1],tcandidat[i].note[2], tcandidat[i].note[3],tcandidat[i].nbchoix);
tcandidat[i].note[3]); for(int y=0;y<tcandidat[i].nbchoix;++y)
for(int y=0;y<tcand[i].nbvoeu;++y) {
{ printf("Ville : %s\n\
printf("Ville : %s\n Departement : %s\n\
Departement : %s\n Décision département : ",tcandidat[i].TabVoeu[y]->ville,tcandidat[i].TabVoeu[y]->dep);
Décision département : ",tcandid[i].ListeVoeu[y].ville,tcandid[i].ListeVoeu[y].dep); if(tcandidat[i].TabVoeu[y]->ddep==0) printf("Dossier non traité\n");
if(==0) printf("Dossier non traité\n"); else
else { {
if(==1) printf("Admis\n"); if(tcandidat[i].TabVoeu[y]->ddep==1) printf("Admis\n");
else { else
if (==2) printf("Liste d'attente\n"); {
if (tcandidat[i].TabVoeu[y]->ddep==2) printf("Liste d'attente\n");
else printf("Refusé\n"); else printf("Refusé\n");
} }
} }
printf("Décision du candidat : ") printf("Décision du candidat : ");
if(==0) printf("Décision non rendu\n"); if(tcandidat[i].TabVoeu[y]->vcand==0) printf("Décision non rendu\n");
else { else
if(==1) printf("Accepté\n"); {
else prinf("Refusé"); if(tcandidat[i].TabVoeu[y]->vcand==1) printf("Accepté\n");
else printf("Refusé");
} }
} }
return; return;
} }
} }
printf("Candidat non trouvé"); printf("Candidat non trouvé");
}
void ListeCandidat(int nbcandidat,candidat *tcandidat)
{
for(int i=0;i<nbcandidat;++i)
{
printf("Candidat n°%d :\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",i,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; return;
}
printf("Candidat non trouvé");
}
void Candidater(VilleIUT* tiut[],int *tlogi, candidat* tcandidat, int numcandid)
{
char VilleRech[31];
printf("Veuillez entrez la ville de l'IUT au quel vous souhaitez candidatez :");
scanf("%s",VilleRech);
int ind=rechercheIUT(tiut,*tlogi,VilleRech);
if(ind==-1) return;
else
{
char DepRech[31];
printf("Veuillez entrez le département dans lequel vous souhaitez y postuler :");
scanf("%s",DepRech);
if (existeDep(tiut[ind]->ldept, DepRech)==0) return;
else
{
int i;
for (i=0;tcandidat[i].numcandid!=numcandid;++i);
voeu* voeu_ajout = (voeu*) malloc (sizeof(voeu));
strcpy(voeu_ajout->ville,VilleRech);
strcpy(voeu_ajout->dep,DepRech);
voeu_ajout->ddep=0;
voeu_ajout->vcand=0;
tcandidat[i].TabVoeu[tcandidat[i].nbchoix]=voeu_ajout;
tcandidat[i].nbchoix++;
}
}
} }
//void gestionPhaseCandidatures(); A FAIRE. //void gestionPhaseCandidatures(); A FAIRE.

@ -1,3 +1,4 @@
typedef struct typedef struct
{ {
char ville[31]; char ville[31];
@ -11,10 +12,14 @@ typedef struct
int numcandid; int numcandid;
char surname[31]; char surname[31];
char name[31]; char name[31];
int note[4]; float note[4];
voeu ListeVoeu[100]; int nbchoix;
voeu* TabVoeu[20];
}candidat; }candidat;
candidat* LoadCandid(void); candidat* LoadCandid(void);
void SaveCandid(int nbcandidat,candidat *tcandidat);
void RechercheCandidat(int ID, int nbcandidat,candidat* tcandidat);
void ListeCandidat(int nbcandidat,candidat *tcandidat);
void Candidater(VilleIUT* tiut[],int *tlogi, candidat* tcandidat,int numcandid);
//void gestionPhaseCandidatures(); A FAIRE. //void gestionPhaseCandidatures(); A FAIRE.

@ -9,6 +9,7 @@
int main(void) int main(void)
{ {
system("clear");
VilleIUT* tiut[36529]; VilleIUT* tiut[36529];
int tlogi=loadIUT(tiut); int tlogi=loadIUT(tiut);
menu(); menu();
@ -28,6 +29,12 @@ int main(void)
case 'S': case 'S':
saveIUT(tiut,tlogi); saveIUT(tiut,tlogi);
reset(); reset();
break;
case 'Q':
printf("Êtes-vous sûr de vouloir quitter ? (Y pour continuer)\n\n");
scanf("%*c%c",&confirmation);
if(confirmation=='Y') quit=1;
system("clear");
} }
saveIUT(tiut,tlogi); saveIUT(tiut,tlogi);
printf("L'application se ferme ..."); printf("L'application se ferme ...");

Loading…
Cancel
Save