/* This program uses code from "Algorithms in C, Third Edition," * by Robert Sedgewick, Addison-Wesley, 1998. */ #include #include typedef struct node * link; struct node { int item; link next; }; main() { link the_list = malloc(sizeof(struct node)); the_list->item = 573; link second_link = malloc(sizeof(struct node)); second_link->item = 100; the_list->next = second_link; link third_link = malloc(sizeof(struct node)); third_link->item = 200; third_link->next = NULL; second_link->next = third_link; printf("\n"); int counter = 0; link current_link; for (current_link = the_list; current_link != 0; current_link = current_link->next) { printf("item %d: %d\n", counter, current_link->item); counter++; } return 0; }