O'Reilly logo

C Primer Plus, Fourth Edition by Stephen Prata

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

  3. 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; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required