strcmp

Compares two character strings

#include <strings.h>
long strcmp (
        const char *s1,
        const char *s2
)

Arguments

s1 Pointer to string 1
s2 Pointer to string 2

Return Value

The result of the comparison is indicated in the return value as shown below:

Result Return Value
s1<s2 <0
s1=s2 =0
s1>s2 >0

Explanation

The string pointed to by s1 is compared with the string pointed to by s2, character-by-character as unsigned chars, and the result is indicated in the return value.