CompuServe Thread

#Proble with qsort

5 messages in this thread
#46195From: Christian BennerMar 19, 1995 11:27 AM
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
#46203From: Clay SpenceMar 19, 1995 7:19 PM
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
#46214From: Christian BennerMar 20, 1995 4:18 PM
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
#46205From: Greg Comeau@Comeau CmptgMar 19, 1995 10:18 PM
>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.
#46215From: Christian BennerMar 20, 1995 4:18 PM
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