Format
#include <wchar.h> int wmemcmp(const wchar_t *s1, const wchar_t *s2, size_t n);
Language Level: ANSI
Threadsafe: Yes.
Description
The wmemcmp() function compares the first n wide characters of the object pointed to by s1 to the first n wide characters of the object pointed to by s2. If n has the value 0, the wmemcmp() function returns 0.
Return Value
The wmemcmp() function returns a value according to the relationship between the two strings, s1 and s2:
Integer Value | Meaning |
---|---|
Less than 0 | s1 less than s2 |
0 | s1 equal to s2 |
Greater than 0 | s1 greater than s2 |
Example that uses wmemcmp()
This example compares the wide-character string in to out using the wmemcmp()function.
#include <wchar.h> #include <stdio.h> #include <locale.h> main() { int rc; wchar_t *in = L"12345678"; wchar_t *out = L"12AAAAAB"; setlocale(LC_ALL, "POSIX"); printf("\nGREATER is the expected result"); rc = wmemcmp(in, out, 3); if (rc == 0) printf("\nArrays are EQUAL %ls %ls \n", in, out); else { if (rc > 0) printf("\nArray %ls GREATER than %ls \n", in, out); else printf("\nArray %ls LESS than %ls \n", in, out); } /****************************************************** The output should be: GREATER is the expected result Array 12345678 GREATER than 12AAAAAB ******************************************************/ }
Related Information
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.