Mail Archives: djgpp/2003/02/08/12:42:45
Do you have RHIDE?
If you do, then press F1, then press Ctrl-G, then type (libc). Click on the
Alphabetical List, then press q. qsort should be the first (and only)
function under q. Then, press enter. Scroll down to the bottom.
Here's the example he was talking about:
======== start of cut-and-paste
Example
-------
typedef struct {
int size;
int sequence;
} Item;
int qsort_helper_by_size(const void *e1, const void *e2)
{
return ((const Item *)e2)->size - ((const Item *)e1)->size;
}
Item list[100];
qsort(list, 100, sizeof(Item), qsort_helper_by_size);
int qsort_stringlist(const void *e1, const void *e2)
{
return strcmp(*(char **)e1, *(char **)e2);
}
char *slist[10];
/* alphabetical order */
qsort(slist, 10, sizeof(char *), qsort_stringlist);
====== end of cut-and-paste
Jason Kircher <cdrradar AT hold DOT odiferous DOT titilating DOT mail DOT com> wrote in message
news:%C91a.6723$kz5 DOT 677340 AT news1 DOT east DOT cox DOT net...
> ams AT ludd DOT luth DOT se wrote:
> > Why don't you "info libc a qsort" and see how the example solves this?
> >
> > Alternatively is should be a safe to use strcmp directly (but don't
> > hold me to this in court), so a functioncast (if possible) would make
> > the compiler quiet.
>
> info... eeech. All I got out of info was a copy of the man page. I
> found qsort in the man pages, but without example. I figured out the
> present usage through (you'll love this) "grep --recursive qsort /*.c"
> I'd love a library reference that HAD examples, or I wouldn't be bald now.
>
- Raw text -