i have this code to print a linklist [1,2,3]
void reverse(struct node *ptr){ head = ptr; while(ptr!=NULL){ printf("%d--->",ptr->data); ptr=ptr->next; } } output : 1-->2-->3
i am trying to print next element of ptr(current node) like
void reverse(struct node *ptr){ head = ptr; while(ptr!=NULL){ printf("%d--->",ptr->data); ptr=ptr->next; printf("%d--->",ptr->data); } } why is not printing 1-->2-->2-->3-->3 ?
NULL->data? Do you understand this?