wcsncasecmp()
QNX SDP8.0C Library ReferenceAPIDeveloper
Compare two wide-character strings, ignoring case, up to a given length
Synopsis:
#include <wchar.h>
int wcsncasecmp( const wchar_t * ws1,
const wchar_t * ws2,
size_t n );
Arguments:
- ws1, ws2
- The strings that you want to compare.
- n
- The maximum number of characters that you want to compare.
Library:
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
Description:
The wcsncasecmp() function compares up to n characters in two strings, specified by ws1 and ws2, ignoring the case of the characters.
Returns:
- < 0
- ws1 is less than ws2.
- 0
- ws1 is equal to ws2.
- > 0
- ws1 is greater than ws2.
Examples:
#include <stdio.h>
#include <wchar.h>
#include <stdlib.h>
static int compare( const wchar_t * ws1, const wchar_t * ws2 )
{
int retval;
retval = wcsncasecmp( ws1, ws2, 3 );
if( retval > 0 ) {
wprintf( "%ls > %ls\n", ws1, ws2 );
} else if( retval < 0 ) {
wprintf( "%ls < %ls\n", ws1, ws2 );
} else {
wprintf( "%ls == %ls\n", ws1, ws2 );
}
return retval;
}
int main( void )
{
const wchar_t * str1 = L"abcdefg";
const wchar_t * str2 = L"HIJ";
const wchar_t * str3 = L"Abc";
const wchar_t * str4 = L"aBCDEfg";
compare( str1, str2 );
compare( str1, str3 );
compare( str1, str4 );
compare( str1, str1 );
compare( str2, str2 );
compare( str2, str3 );
compare( str2, str4 );
compare( str2, str1 );
return EXIT_SUCCESS;
}
This code produces output that looks like:
abcdefg < HIJ
abcdefg == Abc
abcdefg == aBCDEfg
abcdefg == abcdefg
HIJ == HIJ
HIJ > Abc
HIJ > aBCDEfg
HIJ > abcdefg
Classification:
Safety: | |
---|---|
Cancellation point | No |
Signal handler | Yes |
Thread | Yes |
Page updated: