namespace std {
int wmemcmp(const wchar_t* s1, const wchar_t* s2, size_t n);
}
概要
指定した文字数のワイド文字を比較する。
戻り値
先頭からn文字を比較し、s1がs2より大きい場合は正の値、等しい場合は0、小さい場合は負の値を返す。
備考
- ヌル文字も通常の文字として比較される
- この関数は、C++26からフリースタンディング処理系でも使用できる
例
#include <cwchar>
#include <iostream>
int main()
{
std::wcout << (std::wmemcmp(L"abc", L"abd", 2) == 0) << std::endl;
std::wcout << (std::wmemcmp(L"abc", L"abd", 3) < 0) << std::endl;
}
出力
1
1
バージョン
言語
- C++98
関連項目
wcscmpstd::memcmp(): バイト単位版
参照
- P2338R4 Freestanding Library: Character primitives and the C library
- C++26で、この関数がフリースタンディング処理系で使用可能になった