最初の関数は先頭に要素を追加し、セグメンテーション違反を含む2番目の関数は、最初の関数を悪用してジョブを実行することになっています。
#include <stdio.h>
#include <stdlib.h>
typedef struct cellule
{
int val;
struct cellule *suivant;
} cellule;
typedef struct cellule* liste;
liste insert_tete(liste L,int n)
{
liste p;
p=malloc(sizeof(cellule));
p->val=n;
p->suivant=L;
return p;
}//ok :)
liste insert_croissant(liste L,int n)
{
if(!L)
{
L=insert_tete(L,n);
return L;
}
liste p,q;
for(q=L,p=L; (p!=NULL )&&(n> (p->val)) ; q=p,p=p->suivant); //
p=insert_tete(p,n);
q->suivant=p;
return L;
}