I am trying to write a heap sort function using the prototype:
Code:
void
heap_sort(void *base, size_t nel, size_t width, int(*compar)(const void *, const void *));
where base is a pointer to the first element
nel is the number of elements to be sorted
width is the size of each element
and compar is a standard comparison function
(the same prototype for the library function qsort)
I have successfully written a swap_data function and the necessary comparison functions.
I was wondering if anyone can give me some hints on how to do things like setting child = 2 * parent + 1 using these definitions when parent and child are void* items. I keep getting "assignment makes pointer from integer without a cast" and "invalid use of unary *" errors.
Thanks