qsort-Funktion gibt Fehler aus
-
Ich versuche zurzeit ein Winamp Remote Control Programm ein wenig zu verändern (zu finden unter http://www.nullsoft.com/free/wwwinamp) dabei wird die qsort Funktion folgendermaßen benutzt:
qsort(database+oldpos,database_used-oldpos,sizeof(dbType),_compare);
Beim kompilieren tritt allerdings folgender Fehler auf:
1276 C:\Programme\WWWinamp\Source\main.c [Warning] passing arg 4 of `qsort' from incompatible pointer type
Dann muss das wohl an der _compare Funktion liegen. Und diese sieht folgendermaßen aus:
int _compare( const dbType *arg1, const dbType *arg2 ) { int i; char *p; int c1=0,c2=0; p=(char *)(arg1->file); while (*p) { if (*p == '\\' || *p == '/') c1++; p++; } p=(char *)(arg2->file); while (*p) { if (*p == '\\' || *p == '/') c2++; p++; } i=c1-c2; if (!i) i=stricmp(arg1->file,arg2->file); return i; }
Ich kann keinen Fehler erkennen. Findet ihr ihn? Wenn ja dann sagt bitte Bescheid
-
Hallo,
deine compare Funktion muss const void * als Argumente haben, in der Funktion selber kannst/musst du dann immer noch nach dbType casten.
edit:
RechtschreibfehlerMfG
GPC
-
siehe auch http://www.cplusplus.com/ref/cstdlib/qsort.html ..