Pointer List difficulty
I just learned pointers and how to manually make a pointer list. I have something like this: struct node{ int no; node *next = NULL; } The algorithm to add an element to the end of the list looks something like this: nod *s = f; // f is the pointer that points to the start of the list while( s->next != NULL) s = s->next; s->next = new nod; s->next->no = x; //x is a random integer to add to the list Isn't it the same as this one: nod *s = f; // f is the pointer that points to the start of the list while( s != NULL) s = s->next; s = new nod; s->no = x; //x is a random integer to add to the list P.S. : The first algorithm works and the second doesn't. Why?