C/C++ Arena

Step 2 of 6

Push to the front

Real lists allocate nodes on the heap. Adding at the front is the easiest operation: the new node points at the old head, and becomes the new head.

The function has to change the caller's head pointer, so it takes a pointer to the head pointer:

void push_front(struct Node **head, int value);

Your turn: implement it.

Previous: A node that points to a node Next: Length and sum