ProgrammingModerate

A struct P ps[] holds records, and an array of pointers pp[] is sorted with qsort. What happens to the records in ps?

  1. A. They are sorted, because the pointers point into ps
  2. B. They are reversed, because qsort reverses pointers
  3. C. They stay where they are, because only the pointers in pp move
  4. D. They are copied into pp and then deleted

Correct answer: C. They stay where they are, because only the pointers in pp move

Sorting pointers only permutes the pointers. The records keep their memory locations, so ps is unchanged.

More C Programming questions

Exams that ask this topic