Here's the working code:
You gotta take into account the fact that when no node is created in the beginning, there are no nodes to traverse.Code:void InsertItem(currency **list) { currency *temp, *node; temp=(currency*)malloc(sizeof(curr)); fflush(stdin); printf("Vavedi valuta: "); gets(temp->name); printf("Vavedi kod na valutata: "); gets(temp->code); printf("Vavedi stoinost za 1USD: "); scanf("%f", &temp->value); temp->number=++cnt; temp->next=NULL; node=*list; if(node!=NULL) { while(node->next!=NULL) node=node->next; node->next=temp; } else *list=temp; }


Reply With Quote