In-place reversal of a singly linked list As suggested in The 2nd Monitor, I'd like a review of this in-place reversal of a singly linked-list:

#include &lt;iostream&gt;

struct node { 
    int data;
    node *next;
};

node *reverse(node *list) { 
    node *prev = NULL;
    node *next;

    while (list) {
        next = list-&gt;next;
        list-&gt;next = prev;
        prev = list;
        list = next;
    }
    return prev;
}

void show_list(node *list) {
    while (list != NULL) {
        std::cout &lt;&lt; list-&gt;data &lt;&lt; ", ";
        list = list-&gt;next;
    }
}

int main() {
    node *list = NULL;

    for (int i=0; i&lt;10; i++) {
        node *n = new node;
        n-&gt;next = list;
        n-&gt;data = i;
        list = n;
    }

    std::cout &lt;&lt; "As built: ";
    show_list(list);

    list = reverse(list);

    std::cout &lt;&lt; "Reversed: ";
    show_list(list);
    return 0;
}
You don't use delete after allocating nodes with new, resulting in a memory leak.  As a general rule, delete should be used in the same way new was used.

In this case, have an identical for loop and use delete on each node:

for (int i=0; i&lt;10; i++) {
    delete n;
}


With these two loops, you might as well have a constant to hold the number of nodes to use, so that you can make sure the same number is used.
You don't need to have return 0 at the end of main().  Reaching the end implies successful completion, and the compiler will insert this return for you.