There are a couple of obvious ways to use qsort: cast in the comparator:
int cmp(const void *v1, const void *v2)
{
const double *d1 = v1, *d2 = v2;
⋮
}
qsort(p, n, sizeof(double), cmp);
or cast the comparator:
int cmp(const double *d1, const double *d2)
{
⋮
}
qsort(p, n, sizeof(double), (int (*)(const void *, const void *))cmp);
I tend to use the former, more for aesthetic reasons than anything else. Are there any technical reasons for preferring one over the other?