ProgrammingModerate

A sorted array of struct items is searched with bsearch for a key that is not in the array. What does bsearch return?

  1. A. A pointer to the first element
  2. B. A pointer one past the last element
  3. C. A pointer to the element just below the key
  4. D. NULL

Correct answer: D. NULL

bsearch returns NULL when no element compares equal to the key. The caller must test the result before dereferencing it.

More C Programming questions

Exams that ask this topic