Programming Exercises
Modify Listing 17.2 so that it displays the movie list both in the original order and in reverse order. One approach is to modify the linked-list definition so that the list can be traversed in both directions. Another approach is to use recursion.
Suppose list.h (Listing 17.3) uses the following definition of a list:
typedef struct list { Node * head; /* points to head of list */ Node * end; /* points to end of list */ } List;
Rewrite the list.c (Listing 17.5) functions to fit this definition and test the resulting code with the films3.c (Listing 17.4) program.
Suppose list.h (Listing 17.3) uses the following definition of a list:
#define MAXSIZE 100 typedef struct list { Item entries[MAXSIZE]; /* array of items */ int items; ...
Get C Primer Plus, Fourth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.