Hi Michael,
I've finally got around to looking at your C qsort() code
and it works!
I had to correct a few errors before it would compile...
/*
* L I N E S O R T 0
*
* Sort a char array full of nul-terminated strings
*
* Written by M. Stapleton of Graphic Bits
*
* Modified from a Snipet by Bob Lennon
*
* Sep 11 1993
*/
#include
#include
#include
#include
#include
/* Compare Sort Elements */
int pscompare(const void *a, const void *b)
... ^^^^ it didn't like this missing
{
return strcmp(*(char **)a, *(char **)b);
}
#define MAXS 120
#define MAXP MAXS
#define MAXR 26L
/*#define RAND_MAX SHRT_MAX */
... for some reason it didn't like RAND_MAX defined as SHRT_MAX
... so I just used SHRT_MAX. You programmers are strange...
char strs[MAXS]; /* The null-separated strings */
char *strptrs[MAXP]; /* String pointer table */
#define wrand() (rand() & SHRT_MAX)
... ^^^^^^^ it didn't like wrand(z) and rand(z) and I can
... understand that. I don't like it either.
int main(void)
{
unsigned maxpi, pi, si;
char ch=0, **dpch;
/* Fill the string table with random-length alpha strings */
for (si=0; si 9L*SHRT_MAX)
ch = '\0';
else
ch = 'a' + MAXR * wrand() / SHRT_MAX;
strs[si] = ch;
}
strs[MAXS-1] = '\0'; /* Null terminate the table */
/* Build string pointer table */
strptrs[0] = strs;
for (pi=1, si=0; si * Origin: Precision Nonsense, Sydney (3:711/934.12)
SEEN-BY: 711/934 712/610
@PATH: 711/934
|