標準/拡張機能 | C/C++ | 依存項目 |
---|---|---|
ISO C |
両方 |
#include <string.h>
int strcoll(const char *string1, const char *string2);
両方とも、現行ロケールの LC_COLLATE カテゴリーの情報に 応じて解釈される、string1 で示されるストリングと string2 で示されるストリングを比較します。
⁄* CELEBS37
This example compares the two strings passed to main.
*⁄
#include <stdio.h>
#include <string.h>
int main(int argc, char ** argv)
{
int result;
if ( argc != 3 ) {
printf( "Usage: %s string1 string2¥n", argv[0] );
}
else {
result = strcoll( argv[1], argv[2] );
if ( result == 0 )
printf( "¥"%s¥" is identical to ¥"%s¥"¥n", argv[1], argv[2] );
else if ( result < 0 )
printf( "¥"%s¥" is less than ¥"%s¥"¥n", argv[1], argv[2] );
else
printf( "¥"%s¥" is greater than ¥"%s¥"¥n", argv[1], argv[2] );
}
}
出力
"firststring" is less than "secondstring"