How does one manage to <i>publish</i> code that is so badly botched?  <i>[Update: The code in the blog post is fixed; the original versions are below.]</i><p>The recursive solution does not work. It never sets “next” to NULL for the original head of the list, so now the list ends with a cycle.<p>The non-recursive solution does not work either. It never assigns anything to “previous”, so it always returns NULL and sets all of the “next” pointers to NULL.<p>This is easy to see if you actually compile and run both of these on some sample input:<p><pre><code>    #include &#60;stdio.h&#62;
    
    typedef struct Node {
        struct Node *next;
        int value;
    } Node;
    
    Node * reverse( Node * ptr )
    {
        Node * temp;
        if(ptr-&#62;next == NULL) {
            return ptr;
        } else {
            temp = reverse(ptr-&#62;next);
            ptr-&#62;next-&#62;next = ptr;
            return temp;
        }
    }
    
    Node * ireverse( Node * ptr )
    {
        Node * temp;
        Node * previous = NULL;
        while(ptr != NULL) {
            temp = ptr-&#62;next;
            ptr-&#62;next = previous;
            ptr = temp;
        }
        return previous;
    }
    
    void print(Node *head) {
        Node *curr;
        for (curr = head; curr != NULL; curr = curr-&#62;next) {
            printf("%d\n", curr-&#62;value);
        }
    }
    
    main() {
        Node a, b, c;
        a.value = 1;
        a.next = &#38;b;
        b.value = 2;
        b.next = &#38;c;
        c.value = 3;
        c.next = NULL;
        printf("Iterative:\n")
        print(ireverse(&#38;a));
    
        a.value = 1;
        a.next = &#38;b;
        b.value = 2;
        b.next = &#38;c;
        c.value = 3;
        c.next = NULL;
        printf("Recursive:\n")
        print(reverse(&#38;a));
    }</code></pre>