设计一个递归算法,删除不带头结点的单链表L中所有值为x的结点.不知道为什么我的代码运行后不显示结果

#include
#include
typedef struct LNode
{
int data;
struct LNode *next;
}LNode,*Linklist;

void initLinklist(Linklist L)
{
L=NULL;
}
void builtlist(Linklist L)
{
LNode *p,*r=L;
int a[4]={1,2,2,4};
int n=4;
L->data=a[0];
if(n==1)
L->next=NULL;
else
{
for(int i=1;i
{
p=(LNode *)malloc(sizeof(LNode));
p->data=a[i];
r->next=p;
r=r->next;
}
}
}
void deleteLNode(Linklist L,int x)
{
LNode *p;
if(L==NULL)
return;
if(L->data==x)
{
p=L;
L=L->next;
free(p);
deleteLNode(L->next,x);
}
else
deleteLNode(L->next,x);
}

int main()
{
LNode list;
Linklist L=&list;
initLinklist(L);
builtlist(L);
deleteLNode(L,2);
while(L)
{
printf("%d ",L->data);
L=L->next;
}
return 0;
}