compare strings

You're viewing an older version of this page (#3284). View the current version.

View versions (3)

NAME

<span class="Nm" id="strcmp">strcmp</span>, <span class="Nm" id="strncmp">strncmp</span>

INTERFACE

#include <string.h> int strcmp ( const char *s1, const char *s2 ) int strncmp ( const char *s1, const char *s2, size_t len )

DESCRIPTION

The strcmp and strncmp functions lexicographically compare the null-terminated strings &#92;c s1 and &#92;c s2. &#92;n &#92;n The strncmp function compares not more than &#92;c len characters. Because strncmp is designed for comparing strings rather than binary data, characters that appear after a '<span class="Qlq">\\0</span>' character are not compared.

RETURN VALUES

The strcmp and strncmp return an integer greater than, equal to, or less than 0, according as the string &#92;c s1 is greater than, equal to, or less than the string &#92;c s2. The comparison is done using unsigned characters, so that '<span class="Qlq">\\200</span>' is greater than '<span class="Qlq">\\0</span>'.

SEE ALSO

reference:bcmp (3) , memcmp (3) , reference:strcasecmp (3) , strcoll (3) , strxfrm (3)

STANDARDS

The strcmp and strncmp functions conform to