#include #include /* Linked list node structure. */ struct lnode { int cont; struct lnode *next; }; main() { /* Linked list head. */ struct lnode *lhead = NULL; /* Read the list contents. The list is formed in reverse order. */ int newval; while(scanf("%d",&newval) != EOF) { struct lnode *newnode = (struct lnode *)malloc(sizeof(struct lnode)); newnode->cont = newval; newnode->next = lhead; lhead = newnode; } printf("-------------------------------------------------\n"); /* Print the list. */ struct lnode *scan; for(scan = lhead; scan != NULL; scan = scan->next) printf("%d ", scan->cont); printf("\n"); /* Free the list. */ for(scan = lhead; scan != NULL; ) { struct lnode *old = scan; scan = scan->next; free(old); } }