update from main archive 960910
[glibc.git] / stdlib / testsort.c
bloba171a621307b09b9a2277710f532ab491237e7a8
1 #include <ansidecl.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <stdio.h>
6 int
7 DEFUN(compare, (a, b), CONST PTR a AND CONST PTR b)
9 return strcmp (*(char **) a, *(char **) b);
13 int
14 DEFUN_VOID(main)
16 char bufs[500][20];
17 char *lines[500];
18 size_t lens[500];
19 size_t i, j;
21 srandom (1);
23 for (i = 0; i < 500; ++i)
25 lens[i] = random() % 19;
26 lines[i] = bufs[i];
27 for (j = 0; j < lens[i]; ++j)
28 lines[i][j] = random() % 26 + 'a';
29 lines[i][j] = '\0';
32 qsort (lines, 500, sizeof (char *), compare);
34 for (i = 0; i < 500 && lines[i] != NULL; ++i)
35 puts (lines[i]);
37 return 0;