I have seen this in some book/ tutorial.
When you pass in the head pointer (of linked list) into a function, you need to pass it as a double pointer.
For eg:
The reason for the double indirection is so nReverse
can modify the caller's pointer, since after reversing the list, the head of the list is now a different node.
In the second version, you are modifying the copy of head
that is local to the function, so the caller still has a reference to the old head node, which is now the tail.