// *****************ALPHEBETICAL 插入 **************************** ***
struct node *curr;
struct node *trail;
curr = head;
trail = NULL;
while (strcmp(curr->name, new_node->name) < 0 )
{
trail = curr;
curr = curr->next;
}
// if head insertion
if (curr == head)
{
head = new_node;
new_node->next = curr;
}
// if mid insertion
else if ((curr != 0) && (curr != head) )
{
new_node->next = curr;
trail->next = new_node;
}
// if tail insertion
**else if (curr == NULL)
{
trail->next = new_node;
new_node->next = NULL;
}**
}
<块引用>
有人可以解释为什么我在最后一种情况下出现分段错误 - 当尝试在列表末尾插入时吗?