ProgrammingHard

What does strncmp("abc", "xyz", 0) return?

  1. A. a negative value
  2. B. a positive value
  3. C. a value that depends on the strings
  4. D. 0

Correct answer: D. 0

strncmp compares at most n characters. With n = 0 nothing is compared, so the strings count as equal and zero is returned.

More C Programming questions

Exams that ask this topic