I have my comparison function to use in qsort() like this:
int compar(const void *p, const void *q){
interval a,b;
*p = (interval)a
*q = (interval)b;
if(a.extrem[1] < b.extrem[0])
return -1;
if(b.extrem[1] < a.extrem[0] )
return 1;
return 0;
}
My structure is as follows:
typedef struct interval{
double extrem[2];
} interval;
I've tried many variations of "casting" in function compar, which all failed. My question, as it is apparent, how can I cast a const void* to my struct element? I know it seems to be a very basic question but I could not find a clear answer anywhere, also I'm new to this. Any help is gladly appreciated.