I read about a few basic operations in a linked list, and I saw mostly two types of loops
struct node { int data; struct node *next; }*start=NULL,*tmp;
The first cycle had the form
for(tmp=start;tmp->next!=NULL;tmp=tmp->next);
Using the loop above, now the tmp pointer points to the last node in the list
The second loop had the form
tmp=start; while(tmp!=NULL) {
I think they both do the same job, but I'm not sure. Is there any difference?
OneMoreError
source share