← Quiz: Function Pointers in C: all 15 questions
Quiz: Function Pointers in C · Question 5 of 15
Why do qsort comparators take const void parameters?
Why do qsort comparators take const void * parameters?
- A.void pointers are faster
- B.qsort works for any element type, so it passes untyped pointers that the comparator casts to the real type
- C.To stop the array from being sorted
- D.Because C has no int pointers
Answer & explanation
Correct answer: qsort works for any element type, so it passes untyped pointers that the comparator casts to the real type
qsort knows only the element size, not the type; the comparator knows the type.
Can you get the rest right without peeking?
Take the timed Quiz: Function Pointers in C quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →