Ajout de la fonction de chargement des IUTs et repérage de problèmes.

master
Yann CHAMPEAU 3 years ago
parent 2f478e419f
commit 8d2b2b3c79

@ -0,0 +1,21 @@
3
Grenoble
Clermont-Ferrand
Limoges
Aurillac
1
Informatique
112
Dupont Jean
2
Informatique
136
Simon Carine
Biologie
120
Dupond Jean
0
1
Bio-Informatique
56
Duponlt Jeanne

@ -2,6 +2,7 @@
#include <stdlib.h>
#include <errno.h>
#include "saeAnnexe.h"
#include "../partie1/saeP1.h"
void menu(void){
printf("#--------------------------------------------------------------------#\n");
@ -16,11 +17,47 @@ void menu(void){
printf("Choisissez votre session : ");
}
int loadIUT(char* tiut[]){
break//A FAIRE !
int loadIUT(VilleIUT** tiut){
FILE* f=fopen("Etudiants.bin","rb");
MaillonDep* m;
if(f==NULL){
perror("fopen");
exit(errno);
}
int tlogi;
fread(tlogi,sizeof(int),1,f);
for(int i=0; i<tlogi; i++){
fread(tiut[i]->Ville,sizeof(char),31,f);
}
for(i=0; i<tlogi; i++){
int nbIUTs,
fread(nbIUTs,sizeof(int),1,f);
if(nbIUTs){
tiut[i]->ldept=(MaillonDep*)malloc(sizeof(MaillonDep));
if(tiut[i]->ldept==NULL){
perror("malloc");
exit(errno);
}
}
m=tiut[i]->ldept;
for(int j=0; j<nbIUTs; j++){
fread(m->departement,sizeof(char),31,f);
fread(m->nbp,sizeof(int),1,f);
fread(m->resp,sizeof(char),51,f);
if(j<nbIUTs-1){
m->suivant=(MaillonDep*)malloc(sizeof(MaillonDep));
if(m->suivant==NULL){
perror("malloc");
exit(errno);
}
m=m->suiv;
}
}
}
return tlogi;
}
int rechercheTabStr(char* tab[],int lTab,char* mot){
int rechercheTabStr(char* tab[],int lTab,char* mot){/////////////////////////////////////// N O N /////////////////////////////
if(!lTab){
fprintf(stderr,"Erreur, Pas d'éléments dans le tableau !");
return -1;

@ -29,9 +29,9 @@ typedef struct file* File; // //
//
void menu(void); //
//
int loadIUT(char* tiut[]); //
int loadIUT(VilleIUT** tiut); //Fichier Binaire. //
//
int rechercheTabStr(char* tab[],int lTab,char* mot); //
int rechercheTabStr(char** tab[],int lTab,char* mot); ///////////////////////////////////// N O N ////////////////////////////
//
//
//

@ -148,7 +148,7 @@ void modifPlaces(VilleIUT* tiut,int tlogi){
char* ville[31];
scanf("%*c%s",&ville);
if(ville=="Q") return;
int noVille=rechercheTabStr(tiut,tlogi,ville);
int noVille=rechercheTabStr(tiut,tlogi,ville);////////////////////////////// N O N ///////////////////////////////////
if(noVille<=0){
fprintf(stderr,"Ville non existante !");
return;

@ -28,9 +28,9 @@ void SearchIUTFromDep(VilleIUT* lvIUT[],int tlogi);
//Admin
void menuAdmin(VilleIUT* tiut,int tlogi);
void menuAdmin(VilleIUT* tiut,int tlogi);///A CHANGER///
void modifPlaces(VilleIUT* tiut,int tlogi);
void modifPlaces(VilleIUT* tiut,int tlogi);///A CHANGER///
//void creerDep();

@ -9,7 +9,7 @@
int main(void)
{
VilleIUT* tiut;
VilleIUT** tiut;
int tlogi=loadIUT(tiut);
menu();
char user;

Loading…
Cancel
Save