Error in merge sorting of linked list : <p>I am trying to do a merge sorting practice on linked list sort and I couldn't figure the reason that the code doesn't work, my compiler doesn't give any useful error message. Can't someone point it out for me? thanks!</p>

<pre><code>    #include &lt;stdio.h&gt;

    #include &lt;stdlib.h&gt;

    #include &lt;iostream&gt;

    using namespace std;

    struct listnode { struct listnode * next; int key; };

    //function prototypes

    void seperate(struct listnode * node, struct listnode ** front, struct listnode ** back);

    struct listnode * merge(struct listnode * node_1, struct listnode * node_2);

    //merge sorted seperated linked list
    void mergeSort(struct listnode ** node)
    {
    struct listnode * head = * node; struct listnode * node_1; struct listnode * node_2;

    if ((head == NULL) || (head-&gt;next == NULL)) { return; }

    seperate(head, &amp;node_1, &amp;node_2);
    mergeSort(&amp;node_1); mergeSort(&amp;node_2);
    * node = merge(node_1, node_2);

}

//sort sepearted linked list
struct listnode * merge(struct listnode * node_1, listnode * node_2)
{
    struct listnode * return_result = NULL;
    if (node_1 == NULL) { return (node_2); }
    else if (node_2 = NULL) { return (node_1); }

    if (node_1-&gt;key &lt;= node_2-&gt;key)
    {
        return_result = node_1; return_result-&gt;next = merge(node_1-&gt;next, node_2);
    }
    else { return_result = node_2; return_result-&gt;next = merge(node_1, node_2-&gt;next); }

    return return_result;

}

//function to seperate linked list 
void seperate(struct listnode * node, struct listnode ** front, struct listnode ** back)
{
    struct listnode * fast; struct listnode * slow;

    if (node == NULL || node-&gt;next == NULL) { *front = node; * back = NULL; }

    else
    {
        slow = node; fast = node-&gt;next;

        while (fast != NULL)
        {
            fast = fast-&gt;next;
            if (fast != NULL) { slow = slow-&gt;next; fast = fast-&gt;next; }
        }

        * front = node; * back = slow-&gt;next; slow-&gt;next = NULL;

    }


}// merge sort of linked list completed



 //test functions to push and print the linked list  

void push(struct listnode ** head, int data)
{
    struct listnode * added_node = (struct listnode * )malloc(sizeof(struct listnode));
    added_node-&gt;key = data;
    added_node-&gt;next = (*head);
    (*head) = added_node;
}

void printList(struct listnode * node)
{
    while (node != NULL)
    {
        cout &lt;&lt; node-&gt;key;
        node = node-&gt;next;
    }

}

int main()
{
    struct listnode * node1 = NULL;

    push(&amp;node1, 3); push(&amp;node1, 30); push(&amp;node1, 23); push(&amp;node1, 1); push(&amp;node1, 0); push(&amp;node1, 9);
    mergeSort(&amp;node1);
    cout &lt;&lt; endl;
    printList(node1);

    return 0;
}
</code></pre>
