home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_09_09 / 9n09018a < prev    next >
Text File  |  1991-07-09  |  789b  |  44 lines

  1.  
  2. #include <stdio.h>
  3. #include <ctype.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6.  
  7. #include "linklist.h"
  8.  
  9. #define NUMELEM(a) (sizeof(a)/sizeof((a)[0]))
  10.  
  11. Node *proot_node = NULL;    /* start of data list */
  12. Node *ptail_node = NULL;    /* end of data list */
  13. Node *pfree_node = NULL;    /* next free node */
  14.  
  15. unsigned int nodes_in_use = 0;
  16.  
  17. main()
  18. {
  19.     int code;
  20.     static const void (*actions[])(void) = {
  21.         myexit,
  22.         help,
  23.         add_node,
  24.         display_node,
  25.         remove_node,
  26.         dump_asc_nodes,
  27.         dump_des_nodes,
  28.         count_nodes
  29.     };
  30.  
  31.     while (1) {
  32.         printf("\nEnter Action Code (1 for help): ");
  33.         scanf("%2d", &code);
  34.  
  35.         if (code < 0 || code >= NUMELEM(actions)) {
  36.             printf("\n   Invalid command\n");
  37.             continue;
  38.         }
  39.  
  40.         (*actions[code])();    /* call selected action */
  41.     }
  42. }
  43.  
  44.