1STRCMP(3)                  Linux Programmer's Manual                 STRCMP(3)
2
3
4

NAME

6       strcmp, strncmp - compare two strings
7

SYNOPSIS

9       #include <string.h>
10
11       int strcmp(const char *s1, const char *s2);
12
13       int strncmp(const char *s1, const char *s2, size_t n);
14

DESCRIPTION

16       The  strcmp()  function compares the two strings s1 and s2.  The locale
17       is not taken into account (for  a  locale-aware  comparison,  see  str‐
18       coll(3)).   It  returns an integer less than, equal to, or greater than
19       zero if s1 is found, respectively, to be less than,  to  match,  or  be
20       greater than s2.
21
22       The  strncmp()  function  is similar, except it compares only the first
23       (at most) n bytes of s1 and s2.
24

RETURN VALUE

26       The strcmp() and strncmp() functions return an integer less than, equal
27       to, or greater than zero if s1 (or the first n bytes thereof) is found,
28       respectively, to be less than, to match, or be greater than s2.
29

ATTRIBUTES

31       For  an  explanation  of  the  terms  used   in   this   section,   see
32       attributes(7).
33
34       ┌────────────────────┬───────────────┬─────────┐
35Interface           Attribute     Value   
36       ├────────────────────┼───────────────┼─────────┤
37strcmp(), strncmp() │ Thread safety │ MT-Safe │
38       └────────────────────┴───────────────┴─────────┘

CONFORMING TO

40       POSIX.1-2001, POSIX.1-2008, C89, C99, SVr4, 4.3BSD.
41

SEE ALSO

43       bcmp(3),   memcmp(3),   strcasecmp(3),   strcoll(3),  string(3),  strn‐
44       casecmp(3), strverscmp(3), wcscmp(3), wcsncmp(3)
45

COLOPHON

47       This page is part of release 5.02 of the Linux  man-pages  project.   A
48       description  of  the project, information about reporting bugs, and the
49       latest    version    of    this    page,    can     be     found     at
50       https://www.kernel.org/doc/man-pages/.
51
52
53
54                                  2019-03-06                         STRCMP(3)
Impressum