[Previous] [Contents] [Next]

strnicmp()

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

Library:

libc

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.

Returns:

< 0
s1 is less than s2.
0
s1 is equal to s2.
> 0
s1 is greater than s2.

Examples:

#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

Classification:

QNX 4

Safety:
Cancellation point No
Interrupt handler Yes
Signal handler Yes
Thread Yes

See also:

strcmp(), stricmp(), strncmp()


[Previous] [Contents] [Next]