Standards / Extensions | C or C++ | Dependencies |
---|---|---|
ISO C Amendment |
both |
#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);
Compares the first n wide chars of the object pointed to by s1 to the first n wide chars of the object pointed to by s2.
If n has the value 0, wmemcmp() returns 0.
Special behavior for XPG4: If you define any feature test macro specifying XPG4 behavior before the statement in your program source file to include the wchar header, then you must also define the _MSE_PROTOS feature test macro to make the declaration of the wmemcmp function in the wchar header available when you compile your program. Please see Table 1 for a list of XPG4 and other feature test macros.
#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);
}
}