blob: 3ae55b14b9e610479a937624ccf997e719020b09 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
int
compare (const char *a, const char *b)
{
return strcmp (*(char **) a, *(char **) b);
}
int
main (void)
{
char bufs[500][20];
char *lines[500];
size_t lens[500];
size_t i, j;
srandom (1);
for (i = 0; i < 500; ++i)
{
lens[i] = random() % 19;
lines[i] = bufs[i];
for (j = 0; j < lens[i]; ++j)
lines[i][j] = random() % 26 + 'a';
lines[i][j] = '\0';
}
qsort (lines, 500, sizeof (char *), compare);
for (i = 0; i < 500 && lines[i] != NULL; ++i)
puts (lines[i]);
return 0;
}
|