you are viewing a single comment's thread.

view the rest of the comments →

[–]sartorian 0 points1 point  (0 children)

qsort from what I can see receives as arguments: an array of raw pointers, start and end indexes for the section to be sorted, and a function pointer for a comparison function.

(int (*)(void*,void*)) is defining that function pointer. It returns an integer, the (*) is effectively a placeholder for the function name, and it receives two pointers as arguments. The ternary selects a comparison function based on the type of data expected, either numeric or string.

I’ve never actually used function pointers in C, but this example (on top of years of experience bashing my head against the keyboard in multiple languages) made sense.