struct node *next;
void print(struct node *ptr)
What is the output, if a $SLL : 1\rightarrow 2\rightarrow 3\rightarrow 4\rightarrow 5$ is passed in the above $C$ code ?
That was a typo. Corrected now !!
since, while(ptr.next); // ptr is not increased so just prints node 1 infinetly
if, while(ptr=ptr.next); // Then first node twice and all subsequent nodes once
What you are getting as o/p?
Kapil ... To access the structure are you sure that procedure is correct?
AFAIK, to access structure members either (*ptr).data or ptr->data should be correct syntax