création fonction supprimer avec tout ce qui faut (free -> pointeur candidat à règler) et modif du fscanf -> fgets pour le chargement du prénom

master
Alexis LAURENT 2 years ago
parent 1d12c20076
commit 9d37257504

100
SAE.c

@ -215,6 +215,8 @@ void global(void)
tab = chargmentCandid("candidature.txt", &tphys, &nb);
system("clear");
afficherCandid(tab, nb);
supprimerCandid(tab, &nb);
afficherCandid(tab, nb);
}
@ -844,9 +846,103 @@ ChoixDept *traiterCandidDept(int tailleL, int tailleP, FILE *flot)
return cD;
}
int rechCandid(Candidat **tab, int nbEle, int id, int *trouve)
{
int i;
for (i=0; i < nbEle; i++)
{
if (tab[i]->id == id)
{
*trouve = 1;
return i;
}
if (tab[i]->id > id)
{
*trouve = 0;
return i;
}
}
}
void triEchangecandid(Candidat **tab, int nbEle)
{
int pge;
while(nbEle > 1)
{
pge = plusGrandCandid(tab, nbEle);
echangerCandid(tab, pge, nbEle - 1);
nbEle = nbEle - 1;
}
}
int plusGrandCandid(Candidat **tab, int nbEle)
{
int pge = 0, i;
for (i = 1; i < nbEle; i++)
{
if(tab[i]->id > tab[pge]->id)
pge = 1;
return pge;
}
}
void echangerCandid(Candidat **tab, int i, int j)
{
Candidat *aux;
aux = tab[i];
tab[i] = tab[j];
tab[j] = aux;
}
ListeCandid rechCandidIUT(ListeCandid l, char *code)
[
if (l == NULL)
return NULL;
if ((strcmp(code, l->iutCandid)) < 0)
return NULL;
if ((strcmp(code, l->iutCandid)) == 0)
return l;
return rechCandidIUT(l->suiv, code)
]
void supprimerCandid(Candidat **tab, int *nbEle)
{
int idSup;
int idSup, pos, trouve;
while(1)
{
printf("Identifiant de la candidiature à supprimer : ");
scan
scanf("%d", &idSup);
pos = rechCandid(tab, *nbEle, idSup, &trouve);
if (trouve == 0)
{
printf("Candidature non présente dans la base de donnée\n");
break;
}
if (trouve == 1)
if (!confirmationSup())
return;
while(tab[pos]->idCandIUT != NULL)
{
suppressionCandid(tab[pos]->idCandIUT, tab[pos]->idCandIUT->iutCandid, tab[pos]->idCandIUT->tabDept, tab[pos]->idCandIUT->nbChoix);
tab[pos]->idCandIUT = tab[pos]->idCandIUT->suiv;
}
*nbEle = *nbEle - 1;
free(tab[pos]);
triEchangecandid(tab, *nbEle + 1);
if(!verifSelection())
return;
}
}
void créationCandid(Candidat **tab, int *nbEle, int tailleP)
{
char nom[30], prenom[30], dept[30], ville[30];
int idAdd, nbDept, deciCandid, deciDept;
while(1)
{
idAdd = *nbEle;
printf("votre");
}
}

14
SAE.h

@ -144,8 +144,6 @@ void echangerCandidDept(ChoixDept **tDept, int i, int j);
void triEchangeCandidDept(ChoixDept **tDept, int tailleL);
ChoixDept ** insererTDept(ChoixDept **tDept, int tailleP, int tailleL ,char dept[], int deciDept, int deciCandid);
void videTabDept(ChoixDept **tDept, int tailleP);
ListeCandid suppressionEnTeteCandid(ListeCandid l , ChoixDept **tDept, int tailleP);
@ -167,3 +165,15 @@ Candidat lireCandidat(FILE *flot);
ListeCandid traiterCandidIUT(ListeCandid l, FILE *flot);
ChoixDept *traiterCandidDept(int tailleL, int tailleP, FILE *flot);
int rechCandid(Candidat **tab, int nbEle, int id, int *trouve);
void triEchangecandid(Candidat **tab, int nbEle);
int plusGrandCandid(Candidat **tab, int nbEle);
void echangerCandid(Candidat **tab, int i, int j);
ListeCandid rechCandidIUT(ListeCandid l, char *code);
void supprimerCandid(Candidat **tab, int *nbEle);
Loading…
Cancel
Save