compare two strings up to a given length, ignoring case
#include <string.h> int strnicmp( const char *s1, const char *s2, size_t len ); int _strnicmp( const char *s1, const char *s2, size_t len ); int _fstrnicmp( const char __far *s1, const char __far *s2, size_t len );
The strnicmp() function compares, without case sensitivity, the string pointed to by s1 to the string pointed to by s2, for at most len characters.
The _strnicmp() function is identical to strnicmp(). Use _strnicmp() for ANSI/ISO naming conventions.
The _fstrnicmp() function is a data-model-independent form of the strnicmp() function that accepts far pointer arguments. It's most useful in mixed memory model applications.
Value | Meaning |
---|---|
< 0 | s1 is less than s2 |
0 | s1 is equal to s2 |
> 0 | s1 is greater than s2 |
#include <stdio.h> #include <string.h> void main() { 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 ) ); }
produces the output:
-20 -20 0 0
WATCOM
_strnicmp() conforms to ANSI/ISO naming conventions.
Safety: | |
---|---|
Interrupt handler | Yes |
Signal handler | Yes |
Thread | Yes |
strcmp(), stricmp(), strncmp()