#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; printf("Addy before: %u\n", head); append(head); printf("Addy after: %u\n", head); display(head); return 0; } void append (struct person *head) { struct person *tmp, **t; tmp = (struct person *) malloc(sizeof(struct person)); scanf("%s %d", tmp->name, &tmp->age); tmp->next = NULL; printf("HERE1"); t = &head; printf("HERE2"); if(*t != NULL) { printf("HERE3"); while((*t)->next != NULL) { *t = (*t)->next; } (*t)->next = tmp; } else { printf("HERE"); printf("tmp addy: %u\n", tmp); *t = 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) { } }*/ }