Is this the only return value for strcmp() in C?

前端 未结 4 797
小蘑菇
小蘑菇 2021-01-06 17:47

I\'m learning C, and am currently studying String Handling. From where I\'m studying, strcmp() is defined as-

This is a function which c

4条回答
  •  粉色の甜心
    2021-01-06 18:30

    Upon completion, strcmp() shall return an integer greater than, equal to, or less than 0, if the string pointed to by s1 is greater than, equal to, or less than the string pointed to by s2, respectively.

    And you write:

    So, after reading all this, I'm inclined to think that 0, 1 or -1 are the only possible outcomes the strcmp() function.

    Why? It's exactly that the actual value of the returned integer is not specified, only its sign.

提交回复
热议问题