Format
#include <wchar.h>;
int __wcsnicmp(const wchar_t *string1, const wchar_t *string2, size_t count);
Language Level: Extension
Threadsafe: Yes.
Locale Sensitive: The behavior of this function might be affected by the LC_CTYPE category of the current locale if LOCALETYPE(*LOCALE) is specified on the compilation command. The behavior of this function might also be affected by the LC_UNI_CTYPE category of the current locale if LOCALETYPE(*LOCALEUCS2) or LOCALETYPE(*LOCALEUTF) is specified on the compilation command. This function is not available when LOCALETYPE(*CLD) is specified on the compilation command. For more information, see Understanding CCSIDs and Locales.
Wide Character Function: See Wide Characters for more information.
Description
The __wcsnicmp() function compares up to count characters of string1 and string2 without sensitivity to case. All alphabetic wide characters in string1 and string2 are converted to lowercase before comparison.
The __wcsnicmp() function operates on null terminated wide character strings. The string arguments to the function are expected to contain a wchar_t null character (L'\0') marking the end of the string.
Return Value
The__wcsnicmp() function returns a value indicating the relationship between the two strings, as follows:
Value | Meaning |
Less than 0 | string1 less than string2 |
0 | string1 equivalent to string2 |
Greater than 0 | string1 greater than string2 |
.
Example that uses __wcsnicmp()
This example uses __wcsnicmp() to compare two wide character strings.
#include <stdio.h>
#include <wchar.h>
int main(void)
{
wchar_t *str1 = L"STRING ONE";
wchar_t *str2 = L"string TWO";
int result;
result = __wcsnicmp(str1, str2, 6);
if (result == 0)
printf("Strings compared equal.\n");
else if (result < 0)
printf("\"%ls\" is less than \"%ls\".\n", str1, str2);
else
printf("\"%ls\" is greater than \"%ls\".\n", str1, str2);
return 0;
}
/******** The output should be similar to: ***************
Strings compared equal.
***********************************/
Related Information