在C strcmp()的返回值 [英] strcmp() return values in c

查看:131
本文介绍了在C strcmp()的返回值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习有关的strcmp()在C.我的理解是,当两个字符串相等, STRCMP 收益0。

I am learning about strcmp() in C. I understand that when two strings are equal, strcmp returns 0.

然而,当该名男子页指出, STRCMP 当第一个字符串小于第二个字符串返回的值小于0,是指长度,ASCII值,或别的东西吗?

However, when the man pages state that strcmp returns less than 0 when the first string is less than the second string, is it referring to length, ASCII values, or something else?

推荐答案

在这个意义上说,不到的字符串表示字典(字母)顺序。

In this sense, "less than" for strings means lexicographic (alphabetical) order.

所以小于,因为按字母顺序是

So cat is less than dog because cat is alphabetically before dog.

字典顺序,在某种意义上说,按字母顺序排列的延伸到所有ASCII(和UNI code)字符。

Lexicographic order is, in some sense, an extension of alphabetical order to all ASCII (and UNICODE) characters.

这篇关于在C strcmp()的返回值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆