ProgrammingModerate

Which argument is correct as the size parameter in qsort for an array struct P recs[] of n records?

  1. A. sizeof(struct P *)
  2. B. sizeof recs - 1
  3. C. sizeof(recs) / 2
  4. D. sizeof recs[0]

Correct answer: D. sizeof recs[0]

The size is the size of one element. sizeof recs gives the whole array, and a pointer's size is wrong for an array of structs.

More C Programming questions

Exams that ask this topic