Liste chainé supprimer un element
Bonsoir a tous,
Voila j'ai une erreur de segmentation je ne comprends pas trop d'ou elle vient.
Merci d'avance
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
typedef struct cellule
{
int Val;
struct cellule * Suiv;
}Cellule, *Liste;
int EffaceElement(Liste *l, int val)
{
Liste tmp, ptr;
if (*l==NULL) return 0;
if ((*l)->Val==val)
{
ptr=*l;
*l=(*l)->Suiv;
free(ptr);
return 1; /* Succes */
}
while (*l != NULL && (*l)->Val != val)
(*l)=(*l)->Suiv;
if ((*l) == NULL)
return 0; /* Echec */
printf("***");
tmp=(*l)->Suiv;
(*l)->Suiv=(*l)->Suiv->Suiv;
free(tmp);
return 1;
} |