What does strcmp return if two similar strings are of different lengths?

后端 未结 5 1296
庸人自扰
庸人自扰 2021-02-19 15:09

I understand that if you have \'cat\' (string1) and \'dog\' (string2) in strcmp (this is a C question) then the return value of strcmp would be less than 0 (since \'cat\' is lex

5条回答
  •  面向向阳花
    2021-02-19 15:35

    It returns the difference at the octet that differs. In your example '\0' < '2' so something negative is returned.

提交回复
热议问题