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:
In the first example, what you passed in still points to the "beginning" of the list.
In the second example, it points to the end of the list (which was the beginning when you started, but has since moved).