[Previous]
[Contents]
[Next]

strcmp(), _fstrcmp()

compare two strings

Synopsis:

#include <string.h>

int strcmp( const char *s1, const char *s2 );
int _fstrcmp( const char __far *s1,
              const char __far *s2 );

Description:

The strcmp() function compares the string pointed to by s1 to the string pointed to by s2.

The _fstrcmp() function is a data-model-independent form of the strcmp() 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

Examples:

#include <stdio.h>
#include <string.h>

void main()
  {
    printf( "%d\n", strcmp( "abcdef", "abcdef" ) );
    printf( "%d\n", strcmp( "abcdef", "abc" ) );
    printf( "%d\n", strcmp( "abc", "abcdef" ) );
    printf( "%d\n", strcmp( "abcdef", "mnopqr" ) );
    printf( "%d\n", strcmp( "mnopqr", "abcdef" ) );
  }

produces the output:

0
1
-1
-1
1

Classification:

strcmp() is ANSI; _fstrcmp() is WATCOM.
Safety:
Interrupt handler Yes
Signal handler Yes
Thread Yes

See also:

strcmpi(), stricmp(), strncmp(), strnicmp()


[Previous]
[Contents]
[Next]