strnicmp, _strnicmp, _fstrnicmp

compare to strings up to a given length, ignoring case

Synopsis:

#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 );

Description:

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.

Returns:

Value Meaning
< 0 s1 is less than s2
0 s1 is equal to s2
> 0 s1 is greater than s2

See also:

strcmp(), stricmp(), strncmp()

Examples:

#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

Classification:

WATCOM

_strnicmp() conforms to ANSI naming conventions.

Systems:

strnicmp()
All (except DOS/PM)
_strnicmp()
All (except DOS/PM)
_fstrnicmp()
All (except Netware, DOS/PM)