You set head = NULL
at the point where you first defined head
. Except in that one place, we never see head
on the left-hand side of =
anywhere in your program. So of course head
is always equal to NULL
and never anything else.
You will probably want to insert some code at the start of your addNode
function to test whether head == NULL
at that point; and if that is true, you will want to assign the result of memAlo()
to head
instead of curr
. You will have to adjust some of the other logic as well.