Next: strcoll
—locale-specific character string compare, Previous: strchrnul
—search for character in string, Up: Strings and Memory (string.h) [Contents][Index]
strcmp
—character string compareSynopsis
#include <string.h> int strcmp(const char *a, const char *b);
Description
strcmp
compares the string at a to
the string at b.
Returns
If *a
sorts lexicographically after *b
,
strcmp
returns a number greater than zero. If the two
strings match, strcmp
returns zero. If *a
sorts lexicographically before *b
, strcmp
returns a
number less than zero.
Portability
strcmp
is ANSI C.
strcmp
requires no supporting OS subroutines.