標準/拡張機能 | C/C++ | 依存項目 |
---|---|---|
ISO C 改訂 |
両方 |
#include <wchar.h>
int wmemcmp(const wchar_t * __restrict__s1,
const wchar_t * __restrict__s2, size_t n);
#define _XOPEN_SOURCE
#define _MSE_PROTOS
#include <wchar.h>
int wmemcmp(const wchar_t *s1, const wchar_t *s2, size_t n);
s1 が指すオブジェクトの最初の n ワイド文字と s2 が指すオブジェクトの最初の n ワイド文字を 比較します。
n の値が 0 の場合、wmemcmp() は 0 を戻します。
XPG4 の特殊な動作: プログラム・ソース・ファイル内の wchar ヘッダーをインクルードするステートメントより前に、XPG4 の動作を指定してフィーチャー・テスト・マクロを定義した場合には、_MSE_PROTOS フィーチャー・テスト・マクロも定義して、プログラムのコンパイル時に使用可能な wchar ヘッダーに wmemcmp 関数の宣言を行う必要があります。 XPG4 と他のフィーチャー・テスト・マクロのリストについては、表 1 を参照してください。
#include <wchar.h>
#include <stdio.h>
main()
{
int ptr;
wchar_t *in = L"12345678";
wchar_t *out = L"12AAAAAB";
printf("¥nGREATER is the expected result");
ptr = wmemcmp(in, out, 3);
if (ptr == 0)
printf("¥nArrays are EQUAL %ls %ls ¥n",in, out);
else
{
if (ptr > 0)
printf("¥nArray %ls GREATER than %ls ¥n",in, out);
else
printf("¥nArray %ls LESS than %ls ¥n",in, out);
}
}