Standards / Extensions | C or C++ | Dependencies |
---|---|---|
ISO C Amendment |
both |
#include <wchar.h>
int wcscmp(const wchar_t *string1, const wchar_t *string2);
Compares two wide-character strings. The wcscmp() function operates on NULL-terminated wide-character strings. The string arguments to this function must contain a wide NULL character marking the end of the string.
The behavior of this wide-character function is affected by the LC_CTYPE category of the current locale. If you change the category, undefined results can occur.
⁄* CELEBW06
This example compares the wide character string string1 to
string2 using &wcscmp..
*⁄
#include <stdio.h>
#include <wchar.h>
int main(void)
{
int result;
wchar_t string1[] = L"abcdef";
wchar_t string2[] = L"abcdefg";
result = wcscmp( string1, string2 );
if ( result == 0 )
printf( "\"%ls\" is identical to \"%ls\"\n", string1, string2);
else if ( result < 0 )
printf( "\"%ls\" is less than \"%ls\"\n", string1, string2 );
else
printf( "\"%ls\" is greater than \"%ls\"\n", string1, string2);
}
"abcdef" is less than "abcdefg"