compare to 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() and _fstrnicmp() functions compare, 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 naming conventions.
The _fstrnicmp() function is a data-model-independent form of the strnicmp() function that accepts far pointer arguments. It is 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 |
strcmp(), stricmp(), strncmp()
#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 naming conventions.