home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_09_03 / 9n03104b < prev    next >
Text File  |  1991-01-15  |  536b  |  27 lines

  1.  
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5.  
  6. int comp(const void *, const void *);
  7. unsigned char *list[] = { "cat", "car", "cab",
  8.                           "cap", "can" };
  9.  
  10. int main()
  11.     {
  12.     int x;
  13.  
  14.     qsort(list, 5, sizeof(unsigned char *), comp);
  15.     for (x = 0; x < 5; x++)
  16.         printf("%s\n", list[x]);
  17.     return 0;
  18.     }
  19.  
  20. int comp(const void *a, const void *b)
  21.     {
  22.     unsigned **A = (unsigned char **)a;
  23.     unsigned **B = (unsigned char **)b;
  24.     return strcmp(*A, *B);
  25.     }
  26.  
  27.