「cpp/string/char traits/compare」の版間の差分
提供: cppreference.com
< cpp | string | char traits
TranslationBot (トーク | 投稿記録) (Translated from the English version using Google Translate) |
|||
(2人の利用者による、間の4版が非表示) | |||
1行: | 1行: | ||
− | |||
{{cpp/string/char_traits/title|compare}} | {{cpp/string/char_traits/title|compare}} | ||
{{cpp/string/char_traits/navbar}} | {{cpp/string/char_traits/navbar}} | ||
− | {{ | + | {{begin}} |
− | {{ | + | {{ |
− | int compare( const | + | | |
+ | int compare( const * , const * , std::size_t count ); | ||
}} | }} | ||
− | {{ | + | {{ |
+ | |||
+ | |||
+ | |||
+ | end}} | ||
− | + | {{tt|}} と {{tt|}} {{tt|count}} | |
− | + | {{|count}} | |
− | {{ | + | |
− | + | ||
− | + | ||
− | + | ||
− | === | + | ====== |
− | {{ | + | {{}} |
+ | {{| }} | ||
+ | {{| }} | ||
+ | {{}} | ||
− | + | ||
+ | {{tt|}} {{tt|}} '''' | ||
− | {{ | + | {{|{{tt|}} ''''{{|}} |
+ | |||
+ | {{tt|}} {{tt|}} | ||
===例外=== | ===例外=== | ||
− | {{ | + | |
+ | |||
+ | |||
+ | {{|}} | ||
− | + | ||
− | + | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ |
2018年6月15日 (金) 11:37時点における最新版
static int compare( const char_type* s1, const char_type* s2, std::size_t count ); |
(C++17未満) | |
static constexpr int compare( const char_type* s1, const char_type* s2, std::size_t count ); |
(C++17以上) | |
文字列 s1
と s2
の最初の count
個の文字を比較します。 比較は辞書的に行われます。
count
がゼロの場合、文字列は等しいとみなされます。
目次 |
[編集] 引数
s1, s2 | - | 比較する文字列を指すポインタ |
count | - | それぞれの文字列からの比較する文字数 |
[編集] 戻り値
s1
が s2
より小さい場合は負の値。
s1
が s2
と等しい場合は 0。
s1
が s2
より大きい場合は正の値。
[編集] 例外
(なし)
[編集] 計算量
count
に比例。