strcmp
compare strings
You're viewing an older version of this page (#3284). View the current version.
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 \c s1 and \c s2. \n \n The strncmp function compares not more than \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 \c s1 is greater than, equal to, or less than the string \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