结构体链表删除重复数据
void removeDuplicate(struct Node* headNode)
{
printList(headNode);
struct Node* p = headNode->next;
struct Node* q ;
struct Node* leftq = p;
int count = 0;
while (p != NULL)
{
q = p->next;
while (q != NULL)
{
if (!strcmp(p->data.ISBN, q->data.ISBN))
{
leftq->next = q->next;
free(q);
q = leftq->next;
count++;
}
else
{
leftq = q;
q = q->next;
}
}
p = p->next;
leftq = p;
}
}
什么原因