#include #include #include typedef struct node { int number; struct node *next; } node; int main(void) { node *list = NULL; // Create List for (int i = 0; i < 3; i++) { int x = get_int("Number: "); node *n = malloc(sizeof(node)); n->number = x; n->next = list; list = n; if (n == NULL) { printf("Malloc failed. \n"); return 1; } for (node *ptr = list; ptr !=NULL; ptr = ptr->next) { printf("%i\n", ptr->number); } node *ptr = list; while(ptr !=NULL) { node *tmp = ptr; ptr = ptr->next; free(tmp); } } }