我不断得到分段错误,但我不知道为什么,我弄清楚我的分段错误在哪里,但不知道如何解决它。
struct node {
int line;
int count;
char* word;
struct node* next;
};
struct node* nodeGetPreviousNode (struct node* head, struct node* node)
{
//return the previous node given the node
while(((head) != NULL) ||((head)->next != node))
{
(head) = (head)->next;
}
return (head);
}
答案 0 :(得分:8)
while(((head) != NULL) ||((head)->next != node))
将评估(head)->next != node
,在head
为head
NULL
您的意思是使用&&
吗?