设计一个递归算法,删除不带头节点的单链表L中所有值为x的结点,我的代码在Linklist creatlist(L,a,4)这一行报错,说设定初始值太多

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

Linklist creatlist(Linklist L,int a[],int n)
{
LNode *s,*r;
L=(LNode *)malloc(sizeof(LNode));
L->data=a[0];
r=L;
if(n==1)
L->next=NULL;
for(int i=1;i
{
s=(LNode *)malloc(sizeof(LNode));
s->data=a[i];
r->next=s;
r=r->next;
}
return L;
}
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()
{
Linklist L=NULL;
int a[]={1,2,2,4};
int n=4;
Linklist creatlist(L,a,4);
deleteLNode(L,2);
while(L)
{
printf("%d ",L->data);
L=L->next;
}
return 0;
}

main函数中,
Linklist creatlist(L,a,4);
改为
L = creatlist(L,a,4);