#Proble with qsort
5 messages in this thread
Hello,
I have a little problem….
Maybe it`s to late today ..<g>
I have the following struct
struct SysBr {
UBYTE *name;
}*swege;
and I will the names sortet in the array…
My qsort does`n works on this struct…
qsort((char *)&(swege[0]),count,(struct SysBr));
count is the value 15 in my case…
In a other struct I have the same situation only that the UBYTE names[15];
works fine…
Is somebody out there they can help in this case and explain why the qsort
works in the second struct and not in he first ?
Chris
Known as: SYSOP@apd.insider.sub.de 8.5 GBytes Online
Christian_Benner%2:245/6613.8 Mailbox: +49 6384 7582
Really? The second situation works? How is qsort defined in your library? In
Manx and Unix (at least on Sun's library) the third argument is supposed to a
pointer to a function that does the comparison.
Clay
Sorry,
I`ve forget the ,cmp); behind the (struct SysBrt)
he problem was the cmp define…
int *arg1,*arg2 {
return stricmp(arg1->name,arg2->name); }
works fine…
It was to late yesterday.. Sorry…
Thanx for the answer Clay.
Chris
Known as: SYSOP@apd.insider.sub.de 8.5 GBytes Online
Christian_Benner%2:245/6613.8 Mailbox: +49 6384 7582
>qsort((char *)&(swege[0]),count,(struct SysBr));
For starters, that's a syntax error. Please retype in your
sample code again with what works and doesn't, and for that
which doesn't, please say what messages and/or effect you are getting.
Greg,
sorry it was to late yesterday…
qsort((char *)&(swege[0]),count,(struct SysBr),cmp);
The problem was the define for cmp.
int cmp2(arg1,arg2) struct SysBrett *arg1,*arg2; {
return stricmp(arg1->name,arg2->name);
}
works fine….
Thanks for your answer…
Chris
Known as: SYSOP@apd.insider.sub.de 8.5 GBytes Online
Christian_Benner%2:245/6613.8 Mailbox: +49 6384 7582