void append(struct node **p, int item) { struct node *new, *temp; temp = *p; if(*p==NULL) { new = (struct node *) malloc(sizeof(struct node)); new->data = item; new->link = NULL; *p = new; } else { while (temp->link != NULL) temp = temp->link; new = (struct node *) malloc(sizeof(struct node)); new->data = item; new->link = NULL; temp->link = new; } }