Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/Nash_Cyk/article/details/79083031
Gets the number of nodes list, is the most simple, you need to pay attention to whether the list is empty!
int GetListNodeLen(LIST_NODE * m_pHead)
{
if (m_pHead == NULL)
{
return 0;
}
LIST_NODE * pTemp = m_pHead;
int aListLen = 0;
while(pTemp != NULL) //判断当前节点指针是否为空
{
aListLen ++;
pTemp = pTemp->next;
}
return aListLen;
}