In Week 7's Wednesday lecture, Prof. Malan went over the program list-0.c. I don't get why the while
loop in search()
can execute.
The node* ptr
was first set to point at whatever the node* first
is pointing to before executing the loop. Then the loop executes while (ptr != NULL)
. But at the top of this program the node* first
was declared as a global variable and intialized to NULL
. So wouldn't this cause ptr
to be NULL
and the while
loop not to execute altogether?