I am trying to write a heap sort function using the prototype:
where base is a pointer to the first elementCode:void heap_sort(void *base, size_t nel, size_t width, int(*compar)(const void *, const void *));
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.