#include <stdio.h>
struct foo {int x;struct foo * next;};
struct foo * list = NULL;
l_add(int i) {
struct foo* f = (struct foo*) malloc(sizeof(*f));
f->x = i;
if (!list)
f->next = NULL;
else
f->next = list;
list = f;
}
int main() {
int i;
struct foo* f;
for (i=1;i<10;i++) l_add(i);
for (f=list;f;f=f->next)
printf("%d\n",f->x);
/* too lazy to free data */
}
CHAR_DATA *ch, *ch_next;
for (ch = char_list; ch; ch = ch_next)
{
ch_next = ch->next;
// blah blah blah, etc
}
But, this does not:
Diku always uses ch != NULL, which makes sense, but shouldn't ch being TRUE have the
same effect? Does it have to do with the fact that ch->next points to the next node that
is in a sense TRUE, even though it is NULL?