新手求带头结点的单链表尾部插结点的函数写法(C语言),该如何解决

新手求带头结点的单链表尾部插结点的函数写法(C语言)
typedef struct node
{
int i;
struct node* next;
}LNode,*LinkList;
LNode* createNode()
{
LNode *p=(LNode*)malloc(sizeof(LNode));
p->next=NULL;
return p;
}
上面是带头结点的单链表的定义和创建单个结点方法,求一个在单链表尾部添加数据结点的函数
int Insert_LinkList_End(LinkList L,int x);要求返回最后的结点个数(头结点不计数,它不放数据。x为数据不是添加的结点个数


------解决方案--------------------
int Insert_LinkList_End(LinkList L,int x)
{
int i=0;
LinkList S,P=L;

while(P->next)
{
P=P->next;
i++; 


S=CreateNode();
S.i=x;

P->next=S;
S->next=NULL;



return ++i;



}
------解决方案--------------------
int Insert_LinkList_End(LinkList L,int x);中写这个
C/C++ code

int Insert_LinkList_End(LinkList L,int x){
int count=0;
LinkList current=head;
while(current->next!=NULL){
    current=current->next;
    count++;
}
LinkList newnode=createNode();
newnode->i=x;
current->next=newnode;
return count+1;
}