Programming Exercises

  1. 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.

  2. Suppose list.h (refer to 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 (refer to Listing 17.5) functions to fit this definition and test the resulting code with the films3.c (refer to Listing 17.4) program.

  3. Suppose list.h (refer to Listing 17.3) uses the following definition of a list:

     #define MAXSIZE 100 typedef struct list { Item entries[MAXSIZE]; ...

Get C Primer Plus®, Third 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.