Question 5
Back to Exercise
What does strcmp(a, b) return when a comes before b?
- A Exactly -1
- B 0
- C false
- D Some negative value Correct
Correct Answer: Option D
The standard only promises the sign: negative, zero or positive. Many libraries return the difference of the first differing bytes, so test < 0, never == -1.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!