while ( NULL != temp )
{
if ( temp->clint_info.session_id == sessionID )
{
pre->next = temp->next;
delete temp;
temp = NULL;
break;
}
pre = temp;
temp = temp->next;
}
操作链表,需要记住保存前一个结点,以及记录下一个节点,否则容易进入死循环,或者数据出错。
pre = temp;
temp = temp->next;
如果忘记以上其中一条语句都会导致程序出问题。