1

セグメンテーション違反が発生し続けますが、その理由がわかりません。セグメンテーション違反がどこにあるかはわかりましたが、修正方法がわかりません。

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);
}
4

1 に答える 1

8
while(((head) != NULL) ||((head)->next != node))

評価し(head)->next != node、いつであるかを逆参照headheadますNULL

&&代わりに使うつもりでしたか?

于 2013-02-25T13:56:06.987 に答える