Hello everyone, I'm trying to implement qsort on a struct with the double as a pivot:
typedef struct{
char sequence[9];
int occurance;
double prob;
}tuple;
......
int compare (const void *x, const void *y){
if (x < y) return -1;
if (x > y) return 1;
else return 0;
}
...
qsort(x,k,sizeof(tuple),compare);
Now I was trying to access members only to find that it doesn't work.
int compare (const void *x, const void *y){
if (x.prob < y.prob) return -1;
if (x.prob > y.prob) return 1;
else return 0;
}
error: request for member ‘prob’ in something not a structure or union
I was thinking that maybe I have to do something extra, like create a special case of the quicksort algorithm. What would you suggest?