名前空間
変種
操作

std::strcmp

提供: cppreference.com
< cpp‎ | string‎ | byte

 
 
ストリングスライブラリ
NULLで終わる文字列
Original:
Null-terminated strings
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
バイト文字列
文字列をマルチバイト
ワイド文字列
クラス
Original:
Classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_string
char_traits
 
NULL終端バイト文字列
機能します
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
文字操作
Original:
Character manipulation
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
数値形式への変換
Original:
Conversions to numeric formats
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
文字列操作
Original:
String manipulation
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
strcpy
strncpy
strcat
strncat
strxfrm
文字列の検査
Original:
String examination
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
メモリ操作
Original:
Memory manipulation
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
memchr
memcmp
memset
memcpy
memmove
その他
Original:
Miscellaneous
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
strerror
 
Defined in header <cstring>
int strcmp( const char *lhs, const char *rhs );
2 NULL終端バイト文字列を比較します。比較は辞書順で行われ.
Original:
Compares two null-terminated byte strings. The comparison is done lexicographically.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
lhsrhsの両方が有効な文字列を指している必要があります.
Original:
Both lhs and rhs should point to valid strings.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

目次

[編集] パラメータ

lhs, rhs -
比較するNULL終端バイト文字列へのポインタ
Original:
pointers to the null-terminated byte strings to compare
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] 値を返します

lhs場合は、負の値は'rhsより小さい.
Original:
Negative value if lhs is less than rhs.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
0場合lhsです等しいrhs.
Original:
0 if lhs is equal to rhs.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
正の値の場合lhs'より大きいrhs.
Original:
Positive value if lhs is greater than rhs.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集]

#include <vector>
#include <cstring>
#include <algorithm>
#include <iostream>
 
int main() 
{
    std::vector<const char*> cats {"Heathcliff", "Snagglepuss", "Hobbes", "Garfield"};
    std::sort(cats.begin(), cats.end(), [](const char *strA, const char *strB) {
        return std::strcmp(strA, strB) < 0;
    }); 
 
    for (const char *cat : cats) {
        std::cout << cat << '\n';
    }
}

Output:

Garfield
Heathcliff
Hobbes
Snagglepuss

[編集] も参照してください

二つの文字列の文字の一定額を比較します
Original:
compares a certain amount of characters of two strings
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(関数) [edit]
2つのバッファを比較します
Original:
compares two buffers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(関数) [edit]
現在のロケールに応じた2つの文字列を比較する
Original:
compares two strings in accordance to the current locale
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(関数) [edit]
C documentation for strcmp