GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • cpprefjp - C++日本語リファレンス
  • GitHub Project

This view

  • Original page
  • New address

GeezerVison is showing cpprefjp.github.io — std::strcoll - cpprefjp C++日本語リファレンス

  1. リファレンス
  2. cstring
  3. strcoll

最終更新日時: 2026年09月08日 16時51分45秒 (JST)
Akira Takahashi が更新

履歴 編集

function
<cstring>

std::strcoll

namespace std {
  int strcoll(const char* s1, const char* s2);
}

概要

文字列を、ロケールに依存して比較する。

効果

現在のロケールのLC_COLLATEカテゴリに従って、s1が指す文字列とs2が指す文字列を比較する。

戻り値

s1側の文字列がs2側の文字列より大きい場合は正の整数、小さい場合は負の整数を返す。2つの文字列が等しい場合は0を返す。

備考

  • この関数はロケールに依存するため、フリースタンディング処理系では提供されない。
  • ロケールに依存しない単純なバイト単位の比較を行う場合は、strcmpを使用する。

例

#include <cstring>
#include <iostream>

int main()
{
  int r = std::strcoll("apple", "banana");

  std::cout << (r < 0 ? "less" : r > 0 ? "greater" : "equal") << std::endl;
}

出力例

less

バージョン

言語

  • C++98

関連項目

  • strcmp: 文字列を比較する
  • strxfrm: ロケールに基づいて文字列を変換する

参照

  • N3220 7.26.4.3 The strcoll function
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.