pourquoi ce programme ne marche pas qu'elle est l'erreur

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
 
void TabToLsc(cels **l,int tab[40],int n){
	int i,j,x,ok=0;	
	cels *p,*pp;
	cels *nw,*t;
	nw=(cels*)malloc(sizeof(cels));
	p=(cels*)malloc(sizeof(cels));
	i=1;x=1;
	while(x!=n){ok=0;p=*l;
				while((ok!=1)){
				    if (p->note >= tab[i]){
									    	if(p==*l){/*add entete*/ printf("1\n");nw->note=tab[i];nw->suiv=*l;*l=nw;ok=1;p=*l;x++;
						                             }else{/*add m avant*/printf("2\n");nw->note=tab[i];nw->suiv=p;pp->suiv=nw;ok=1;x++;}
					}else if (p->note < tab[i]){
												if(p->suiv==NULL){/*add fin*/printf("3\n");nw->note=tab[i];nw->suiv=NULL;p->suiv=nw;ok=1;x++;
																 }else{printf("4\n"); pp=p;p=p->suiv;}
						                        }
		  		           } i++;p=*l;
 	                }
}
int main()
{
    cels *l;
    l=(cels*)malloc(sizeof(cels));
     int n,a,i;
      int tab[40];
 
      printf ("donnez la taille n ");
      scanf("%d",&n);
 
      for(i=0;i<n;i++)
      {
      printf ("donnez la valeur d case n° %d :",i);
      scanf("%d",&tab[i]);
      }
   l->note=tab[0];
    l->suiv=NULL;
 
	TabToLsc(&l,tab,n);
	affichage(l);
 
  system("PAUSE");	
  return 0;
}
et Merci d'avance