home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_09_05 / 9n05022c < prev    next >
Text File  |  1991-03-18  |  807b  |  43 lines

  1.  
  2. #include <stdio.h>
  3.  
  4. #define NUMELEM(a) (sizeof(a)/sizeof(a[0]))
  5.  
  6. const char cm0[] = "ADD";
  7. const char cm1[] = "DELETE";
  8. const char cm2[] = "LIST";
  9. const char cm3[] = "REPLACE";
  10. const char *level0[] = {cm2, NULL};
  11. const char *level1[] = {cm0, cm2, cm3, NULL};
  12. const char *level2[] = {cm0, cm1, cm2, cm3, NULL};
  13. const char **mode[] = {level0, level1, level2};
  14.  
  15. main()
  16. {
  17.     int i, j;
  18.  
  19.  
  20.     for (i = 0; i < NUMELEM(mode); ++i) {
  21.         printf("\nLevel %d commands: ", i);
  22.         for (j = 0; mode[i][j] != NULL; ++j)
  23.             printf("  %s", mode[i][j]);
  24.  
  25.         putchar('\n');
  26.     }
  27. }
  28.  
  29.  
  30. output:
  31.  
  32. Level 0 commands:   LIST
  33.  
  34. Level 1 commands:   ADD  LIST  REPLACE
  35.  
  36. Level 2 commands:   ADD  DELETE  LIST  REPLACE
  37.  
  38.  
  39.  
  40.  
  41. {pasteup: be sure to leave blank lines in between the
  42.           lines in the output}
  43.