i want to print my linked list in the reverse order ie..last item first and first item last..this is what i have so far
Code:
struct linked_list { int number; struct linked_list *next; }; typedef linked_list node; void main() { void create(node *); void print(node *); clrscr(); node *head; head=(node*)malloc(sizeof(node)); create(head); print(head); getch(); } void create(node *p) { printf("Enter the number : \n"); scanf("%d",&p->number); if(p->number==999) { p->next=NULL; } else { p->next=(node*)malloc(sizeof(node)); create(p->next); } return; } void print(node *p) { if(p->next!=NULL) { printf("%d-->",p->number); print(p->next); } }
Comment