#include #include int main (int argc, char**argv) { struct List { int elem; struct List *next; }; struct List *list = NULL; struct List *tmp; struct List *previous = NULL; int n; while (fscanf (stdin, "%d", &n)> 0) { /* allocate memory for next element */ tmp = malloc(sizeof (struct List)); if (tmp == NULL ) { fprintf (stderr, "%s: Out of memory!\n", argv[0]); exit (1); } if (list == NULL) { list = tmp; } tmp->elem = n; tmp->next = NULL; if (previous != NULL) { previous->next = tmp; } previous = tmp; } while (list != NULL) { printf ("%s: The next element is %d\n", argv[0], list->elem); list = list->next; } return 0; }