Pointer black magic

Hi,

I came across a source code which was using a compareing function for quicksort(qsort()). I quite don't understand what it does with the pointers. Can you please help me? Thanks.

Here is the function:

int compare(const void *x, const void *y) { return *(int*)x-*(int*)y; }

It is using a c-style cast (int*) to cast the void pointers to int pointers before dereferencing them and subtracting the values pointed to.
Aha! Thanks.
Topic archived. No new replies allowed.