bonsoir je voudrai faire une fonction qui ajout un element à la fion d'une liste chainée et je n'y arrive pas voila ma fonction:
#include <stdio.h>
#include <stdlib.h>
struct chaine {
int valeur;
struct chaine*suivant;
};
typedef struct chaine*liste;
void inserer_fin (liste l, int b);
main ()
{liste l; liste p; int a;
do{
printf ("Entrer 1 entier \n");
scanf ("%d ", &a);
p=(liste)malloc(sizeof(struct chaine));
p->valeur =a;
p-> suivant = l;
l=p;
}
while (a!=0);
free (p);
inserer_fin (l,3);
}
void inserer_fin (liste l, int b)
{liste h;
liste g;
h-> valeur = b;
g=l;
while (g!=NULL){
g=g->suivant;
}
h=(liste) malloc (sizeof (struct chaine));
g=(liste) malloc (sizeof (struct chaine));
g=h;
g->suivant = h->suivant;
l=g;
free(h);
free(g);
}
merci pour votre aide
beatkof