#include #include #include struct person { char name[25]; int age; struct person *next; }; void append (struct person **head); void display(struct person *h); int main(int argc, char *argv[]) { struct person * head = NULL; append(&head); append(&head); display(head); return 0; } void append (struct person **head) { struct person *tmp, **currentNode; tmp = (struct person *) malloc(sizeof(struct person)); scanf("%s %d", tmp->name, &tmp->age); tmp->next = NULL; currentNode = head; if(*currentNode != NULL) { while((*currentNode)->next != NULL) { *currentNode = (*currentNode)->next; } (*currentNode)->next = tmp; } else { *head = tmp; } } void display(struct person *h) { struct person *tmp; tmp = h; while(tmp != NULL) { printf("%s\t%i\n", tmp->name, tmp->age); tmp = tmp->next; } } void insert_first(struct person *head) { struct person *tmp; tmp = (struct person *) malloc(sizeof(struct person)); scanf("%s %d", tmp->name, &tmp->age); tmp->next = NULL; tmp->next = head; head = tmp; } void insert(struct person * head) { int pos, i = 0; struct person *tmp, *t = head; scanf("%d", &pos); tmp = (struct person *) malloc(sizeof(struct person)); scanf("%s %d", tmp->name, &tmp->age); tmp->next = NULL; while(t != NULL) { if(pos == i) { tmp->next = t->next; t->next = tmp; } i ++; t = t->next; } } void remove_all(struct person * head) { struct person * tmp = head, *h; while(tmp != NULL) { h = tmp; tmp = tmp->next; free(h); } head = NULL; } void removeAt(struct person *head) { int pos, i = 0; struct person *tmp; scanf("%d", &pos); tmp = head; /* while(tmp != NULL) { if(pos == i) { } }*/ }