Ok so I'm still a little confused with how I could get that to do it for the
skill table....

Would I do
qsort(skill_table, MAX_SKILL, sizeof(skill_table), compare);

And then in my comparison function how would I work that out?

int compare(const void *a, const void *b)
{
    struct skill_type *skill1, *skill2;
    int count1;

    skill1 = (struct skill_type *)a;
    skill2 = (struct skill_type *)b;

    for(count =0; skill1.name[count] != '\0' || skill2.name[count] != '\0';
count++)
    {
                if(LOWER(skill1.name[count1]) == LOWER(skill2.name[count])
                    continue;

                return (LOWER(skill1.name[count]) -
LOWER(skill2.name[count]));
    }

    return 0;
}


Is that how I would do this? Sorry if that looks retarted, just I've never
seen or used this qsort ablity. And I've never compared letters to each
other. I normal compare with str_prefix, for str_cmp.

----- Original Message -----
From: "Michael Barton" <[EMAIL PROTECTED]>
To: "Dale Kingston" <[EMAIL PROTECTED]>; <[email protected]>
Sent: Tuesday, April 29, 2003 4:58 PM
Subject: Re: Sorting skills Alphabeticly


> qsort can sort any way you want, you just have to provide your own
> comparison function.
>
> from qsort(3)
> The  comparison  function  must return an integer less than, equal to, or
> greater than zero if the first argument is considered to be respectively
> less than, equal to, or greater than the second.  If two  members compare
as
> equal, their order in the sorted array is undefined.
>
> from strcmp(3)
> The strcmp() function compares the two strings s1 and s2.  It returns an
> integer less than, equal to, or greater than zero if s1 is found,
> respectively, to be less than, to match, or be greater than s2.
>
> See how nicely that works out?
>
> ----- Original Message -----
> From: "Dale Kingston" <[EMAIL PROTECTED]>
> To: <[email protected]>
> Sent: Tuesday, April 29, 2003 4:31 PM
> Subject: Re: Sorting skills Alphabeticly
>
>
> > How would I go about using qsort for an alpha sorting, looks like it
just
> > does numbers.
> >
> > ----- Original Message -----
> > From: "Charles" <[EMAIL PROTECTED]>
> > To: "Dale Kingston" <[EMAIL PROTECTED]>
> > Cc: <[email protected]>
> > Sent: Tuesday, April 29, 2003 11:15 AM
> > Subject: Re: Sorting skills Alphabeticly
> >
> >
> > > qsort
> > >
> > > ----- Original Message -----
> > > From: "Dale Kingston" <[EMAIL PROTECTED]>
> > > To: <[email protected]>
> > > Sent: Tuesday, April 29, 2003 10:03 AM
> > > Subject: Sorting skills Alphabeticly
> > >
> > >
> > > > I was wondering if anyone knew of a library or away that I could
sort
> > > > something alphabeticly. I'm having a problem with a new skill I
added
> > > cause
> > > > it's called shock. And I have a skill that comes before it in the
> table
> > > > called shocking blade so now I can't edit shock and it won't give it
> to
> > > the
> > > > class as a basic cause that class doesn't get shocking blade. So any
> > help
> > > on
> > > > a library or a way that I could sort alphabeticly would be nice. I'm
> > using
> > > > if you curious olc 2.01+ I know how to work with the table I just
> wasn't
> > > > sure if a skill_table[sn].name[0] > skill_table[sn+1].name[0] type
of
> > > thing
> > > > would work or not. Thanks in advance
> > > >
> > > >
> > > > --
> > > > ROM mailing list
> > > > [email protected]
> > > > http://www.rom.org/cgi-bin/mailman/listinfo/rom
> > >
> > >
> > >
> > > --
> > > ROM mailing list
> > > [email protected]
> > > http://www.rom.org/cgi-bin/mailman/listinfo/rom
> > >
> >
> >
> > --
> > ROM mailing list
> > [email protected]
> > http://www.rom.org/cgi-bin/mailman/listinfo/rom
>
>
> --
> ROM mailing list
> [email protected]
> http://www.rom.org/cgi-bin/mailman/listinfo/rom
>


Reply via email to