I have a little problem there with error by using function qsort, it shows me:
[Note] initializing argument 4 of 'void qsort(void*, size_t, size_t, int (*)(const void*, const void*))'
it also shows the error:
[Error] invalid conversion from 'int (*)(const student*, const student*)' to 'int (*)(const void*, const void*)' [-fpermissive]
int n;
qsort ((void*) databaza, size, sizeof(struct student), compare);
for (n=0; n<size; n++)
{
printf ("%d %s",databaza[SIZE].votes,databaza[SIZE].name);
}
return 0;
where the compare function looks like
int compare(const struct student* p1, const struct student* p2){
return ( p1->votes - p2->votes );
}
in structure
struct student {
char name[SIZE];
int votes;
};
int find_student(struct student* students,int size, const char* name){
for(int i = 0;i < size;i++){
int results=strcmp(students[i].name,name);
if(results==0){
return i;
}
}
return -1;
}
Can anyone tell me why is this happening, I am quite new in structures and functions like qsort.