Compare two strings up to a given length, ignoring case
#include <string.h> int strnicmp( const char* s1, const char* s2, size_t len );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The strnicmp() function compares up to len characters from the strings pointed to by s1 and s2, ignoring case.
#include <stdio.h> #include <stdlib.h> #include <string.h> int main( void ) { printf( "%d\n", strnicmp( "abcdef", "ABCXXX", 10 ) ); printf( "%d\n", strnicmp( "abcdef", "ABCXXX", 6 ) ); printf( "%d\n", strnicmp( "abcdef", "ABCXXX", 3 ) ); printf( "%d\n", strnicmp( "abcdef", "ABCXXX", 0 ) ); return EXIT_SUCCESS; }
produces the output:
-20 -20 0 0
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | Yes |
Signal handler | Yes |
Thread | Yes |
strcasecmp(), strcmp(), strcmpi(), strcoll(), stricmp(), strncasecmp(), strncmp(), wcscmp(), wcscoll(), wcsncmp()