[Previous]
[Contents]
[Next]

stricmp(), _stricmp(), _fstricmp()

compare two strings, ignoring case

Synopsis:

#include <string.h>
int stricmp( const char *s1, const char *s2 );
int _stricmp( const char *s1, const char *s2 );
int _fstricmp( const char __far *s1,
               const char __far *s2 );

Description:

The stricmp() function compares, with case insensitivity, the string pointed to by s1 to the string pointed to by s2. All uppercase characters from s1 and s2 are mapped to lowercase for the purposes of doing the comparison.

The _stricmp() function is identical to stricmp(). Use _stricmp() for ANSI/ISO naming conventions.

The _fstricmp() function is a data-model-independent form of the stricmp() 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", stricmp( "AbCDEF", "abcdef" ) );
    printf( "%d\n", stricmp( "abcdef", "ABC"    ) );
    printf( "%d\n", stricmp( "abc",    "ABCdef" ) );
    printf( "%d\n", stricmp( "Abcdef", "mnopqr" ) );
    printf( "%d\n", stricmp( "Mnopqr", "abcdef" ) );
  }

produces the output:

0
100
-100
-12
12

Classification:

WATCOM

_stricmp() conforms to ANSI/ISO naming conventions.

Safety:
Interrupt handler Yes
Signal handler Yes
Thread Yes

See also:

strcmp(), strcmpi(), strncmp(), strnicmp()


[Previous]
[Contents]
[Next]