Linked list head double pointer passing

前端 未结 5 2280
一生所求
一生所求 2020-12-17 05:21

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:

5条回答
  •  感情败类
    2020-12-17 06:01

    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).

提交回复
热议问题