I'm curious as to why when say I traverse a linked list iteratively I must do while (list != NULL)
instead of while (!list)
. I thought NULL equated to zero or false.
From comments: My program seems to always crash when I attempt a while (!list)
but never the former. Each node contains a void pointer to a piece of data and a pointer to the next node.
axiac :
while (list != NULL) is not the same as while (!list). They are opposites! Of course your program crashes, it tries to de-reference a NULL pointer.\n\nwhile (list != NULL) is the same as while (list).",
2016-04-06T09:25:24