diff --git a/src/partie1/saeP1.c b/src/partie1/saeP1.c index 5b1aefd..20425ab 100644 --- a/src/partie1/saeP1.c +++ b/src/partie1/saeP1.c @@ -352,7 +352,7 @@ void modifNomResponsable(VilleIUT* tiut[],int tlogi){ VilleIUT* v=tiut[noVille]; printf("\n\nEntrez le département à modifier:"); char dep[31]; - scanf("%s",dep); + scanf("%*c%s",dep); if(!existeDep(v->ldept,dep)){ fprintf(stderr,"\nDépartement non existant !\n"); return; @@ -360,10 +360,9 @@ void modifNomResponsable(VilleIUT* tiut[],int tlogi){ MaillonDep* m=v->ldept; 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); - char nom[51]; - scanf("%s",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); + scanf("%*c"); + fgets(m->resp, 51, stdin); + printf("\n\nLe nom du responsable du département %s de l'IUT de %s a bien été changé pour %s.\n",dep,ville,m->resp); return; } diff --git a/src/partie2/saeP2.c b/src/partie2/saeP2.c index faad6be..edaa2a3 100644 --- a/src/partie2/saeP2.c +++ b/src/partie2/saeP2.c @@ -17,20 +17,20 @@ candidat** LoadCandid(int* CandidOpen, int* nbcandid) fread(CandidOpen,sizeof(int),1,file); //Lire la première ligne pr savoir combien d'étudiant je vais lire fread(nbcandid,sizeof(int),1,file); - candidat** Tabcandidat=(candidat**) malloc (sizeof(candidat)*(*nbcandid)); + 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= (candidat*) malloc (sizeof(candidat)); - 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); + Tabcandidat[i]=(candidat*)malloc(sizeof(candidat)); + fread(&Tabcandidat[i]->numcandid,sizeof(int),1,file); + fread(Tabcandidat[i]->surname,sizeof(char)*31,1,file); + fread(Tabcandidat[i]->name,sizeof(char)*31,1,file); + fread(Tabcandidat[i]->note,sizeof(float)*4,1,file); //Son nb de choix - fread(&Candidat_ajout->nbchoix,sizeof(int),1,file); + fread(&Tabcandidat[i]->nbchoix,sizeof(int),1,file); //Tant que j'ai pas fait tout ces choix : - for(int y=0;ynbchoix;++y) + for(int y=0;ynbchoix;++y) { //Je lis La ville, le département, la décision du dep, la validation du candidat voeu* voeu_ajout=(voeu*)malloc(sizeof(voeu)); @@ -38,9 +38,8 @@ candidat** LoadCandid(int* CandidOpen, int* nbcandid) 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]->TabVoeu[i]=voeu_ajout; } - Tabcandidat[i]=Candidat_ajout; } //Je sors return Tabcandidat;