首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::char_traits::compare

static int compare( const char_type* s1, const char_type* s2, std::size_t count );

(until C++17)

static constexpr int compare( const char_type* s1, const char_type* s2, std::size_t count );

(since C++17)

比较第一个count字符串的字符s1s2.比较是按字典顺序进行的。

如果count是零,字符串被认为是相等的。

参数

s1, s2

-

pointers to character strings to compare

count

-

the number of characters to compare from each character string

返回值

负值s1少于s2...

​0​如果s1等于s2...

正值s1大于s2...

例外

%280%29

复杂性

线性在count...

代码语言:txt
复制
 © cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券