C数据结构获取链表长度

int getListLength(LinkList*list)
{
int n=0;
LinkList*p=list;
while(p->next!=NULL)
{
n++;
p=p->next;
}
printf("链表长度为:%d\n\n",n);
return n;
}
//建立节点
LinkList *createNode()
{
LinkList *node=(LinkList*)malloc(sizeof(LinkList));
node->next=NULL;
return node;
}

猜你喜欢

转载自www.cnblogs.com/ruanwuyinbiao/p/10823050.html