Machine-translated by Google. Questions are authored in English.
Top

Discussion

If the two strings are identical, then strcmp() function returns

  • A.-1
  • B.1
  • C.Yes
  • D.0

Answer: D

Correct answer: 0

strcmp returns 0 when the strings are identical, a negative value when the first sorts before the second, and a positive one when it sorts after. Returning 0 for a match is what makes if (strcmp(a, b)) such a common mistake - it is true when the strings differ.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.