LearnFrenzy
Sign in Take a free test

Strings · String Basics MCQ · Question 5

What does strcmp() return in C? Answer, explanation & discussion

  • MCQ
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
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!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links