[Previous]
[Contents]
[Next]

strnicmp(), _strnicmp(), _fstrnicmp()

compare two 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() 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.

Returns:

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

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/ISO naming conventions.

Safety:
Interrupt handler Yes
Signal handler Yes
Thread Yes

See also:

strcmp(), stricmp(), strncmp()


[Previous]
[Contents]
[Next]