Modification de la fonction loadIUT.

master
Yann CHAMPEAU 3 years ago
parent 93bb8c24e3
commit 21f38dd23b

@ -20,19 +20,18 @@ void menu(void){
printf("Choisissez votre session : "); printf("Choisissez votre session : ");
} }
int loadIUT(VilleIUT** tiut){ VilleIUT** loadIUT(VilleIUT** tiut, int* tlogi){
FILE* f=fopen("Etudiants.bin","rb"); FILE* f=fopen("Etudiants.bin","rb");
if(f==NULL){ if(f==NULL){
perror("fopen"); perror("fopen");
exit(errno); exit(errno);
} }
MaillonDep* m; MaillonDep* m;
int tlogi; fread(tlogi,sizeof(int),1,f);
fread(&tlogi,sizeof(int),1,f); for(int i=0; i<*tlogi; i++){
for(int i=0; i<tlogi; i++){
fread(tiut[i]->Ville,sizeof(char),31,f); fread(tiut[i]->Ville,sizeof(char),31,f);
} }
for(int i=0; i<tlogi; i++){ for(int i=0; i<*tlogi; i++){
int nbIUTs; int nbIUTs;
fread(&nbIUTs,sizeof(int),1,f); fread(&nbIUTs,sizeof(int),1,f);
if(nbIUTs){ if(nbIUTs){
@ -57,7 +56,7 @@ int loadIUT(VilleIUT** tiut){
} }
} }
} }
return tlogi; return tiut;
} }
void saveIUT(VilleIUT** tiut, int tlogi){ void saveIUT(VilleIUT** tiut, int tlogi){

@ -29,11 +29,11 @@ typedef struct file* File; // //
// //
void menu(void); // void menu(void); //
// //
int loadIUT(VilleIUT** tiut); // VilleIUT** loadIUT(VilleIUT** tiut, int* tlogi); //
// //
void saveIUT(VilleIUT** tiut, int tlogi); // void saveIUT(VilleIUT** tiut, int tlogi); //
// //
int rechercheIUT(VilleIUT* tab[],int lTab,char mot[]); // int rechercheIUT(VilleIUT* tab[],int lTab,char mot[]); //
// //
// //
// //

@ -11,7 +11,8 @@ int main(void)
{ {
system("clear"); system("clear");
VilleIUT* tiut[36529]; VilleIUT* tiut[36529];
int tlogi=loadIUT(tiut), quitter=0; int tlogi, quitter=0;
tiut=loadIUT(tiut,&tlogi),
while(!quitter){ while(!quitter){
menu(); menu();
char user; char user;

Loading…
Cancel
Save