diff --git a/src/partie1/saeP1.c b/src/partie1/saeP1.c index f932f17..84e5ae2 100644 --- a/src/partie1/saeP1.c +++ b/src/partie1/saeP1.c @@ -267,8 +267,16 @@ void creerDep(VilleIUT* tiut[],int tlogi){ } } MaillonDep* m=v->ldept; + printf("\n\nEntrez le nom du département à créer : "); + char nomDep[31] + scanf("%*c%s",nomDep); if(!ck){ - while(m->suivant!=NULL) m=m->suivant; + if(m->suivant==NULL){ + if(strcmp(nomDep,m->departement)>0){ + m=m->suivant; + } + } + while(strcmp(nomDep,m->suivant)>0) m=m->suivant; m->suivant=(MaillonDep*)malloc(sizeof(MaillonDep)); if(m->suivant==NULL){ perror("malloc"); @@ -276,8 +284,7 @@ void creerDep(VilleIUT* tiut[],int tlogi){ } m=m->suivant; } - printf("\n\nEntrez le nom du département à créer : "); - scanf("%*c%s",m->departement); + m->departement=nomDep; printf("\n\nEntrez le nombre de places disponibles dans le département : "); scanf("%d",&m->nbp); printf("\n\nEntrez le nom du responsable de département : \n");