home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / prof_c / 07config / tstsel.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-08-11  |  924 b   |  51 lines

  1. /*
  2.  *    tstsel -- test driver for the "select" functions
  3.  */
  4.  
  5. #include <stdio.h>
  6. #include <local\std.h>
  7.  
  8. #define MAXTEST    20
  9. #define NRANGES    10
  10. #define NDIGITS    5
  11.  
  12. extern struct slist_st {
  13.     long int s_min;
  14.     long int s_max;
  15. } Slist[NRANGES + 1];
  16.  
  17. main (argc, argv)
  18. int argc;
  19. char **argv;
  20. {
  21.     int i;
  22.     extern int mkslist(char *);
  23.     extern int selected(unsigned int);
  24.     static void showlist();
  25.  
  26.     if (argc != 2) {
  27.         fprintf(stderr, "Usage: tstsel list\n");
  28.         exit(1);
  29.     }
  30.     printf("argv[1] = %s\n", argv[1]);
  31.     mkslist(argv[1]);
  32.     showlist();
  33.     for (i = 0; i < MAXTEST; ++i)
  34.         printf("%2d -> %s\n", i, selected(i) ? "YES" : "NO");
  35.     exit(0);
  36. }
  37.  
  38. /*
  39.  *    showlist -- display the contents of the select list
  40.  */
  41.  
  42. static void
  43. showlist()
  44. {
  45.     int i;
  46.  
  47.     /* scan the selection list and display values */ 
  48.     for (i = 0; i <= NRANGES; ++i)
  49.         printf("%2d %5ld %5ld\n", i, Slist[i].s_min, Slist[i].s_max);
  50. }
  51.