]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/strcmp.3
getent.1, iconv.1, ldd.1, locale.1, localedef.1, memusage.1, memusagestat.1, pldd...
[thirdparty/man-pages.git] / man3 / strcmp.3
CommitLineData
fea681da
MK
1.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2.\"
93015253 3.\" %%%LICENSE_START(VERBATIM)
fea681da
MK
4.\" Permission is granted to make and distribute verbatim copies of this
5.\" manual provided the copyright notice and this permission notice are
6.\" preserved on all copies.
7.\"
8.\" Permission is granted to copy and distribute modified versions of this
9.\" manual under the conditions for verbatim copying, provided that the
10.\" entire resulting derived work is distributed under the terms of a
11.\" permission notice identical to this one.
c13182ef 12.\"
fea681da
MK
13.\" Since the Linux kernel and libraries are constantly changing, this
14.\" manual page may be incorrect or out-of-date. The author(s) assume no
15.\" responsibility for errors or omissions, or for damages resulting from
16.\" the use of the information contained herein. The author(s) may not
17.\" have taken the same level of care in the production of this manual,
18.\" which is licensed free of charge, as they might when working
19.\" professionally.
c13182ef 20.\"
fea681da
MK
21.\" Formatted or processed versions of this manual, if unaccompanied by
22.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 23.\" %%%LICENSE_END
fea681da
MK
24.\"
25.\" References consulted:
26.\" Linux libc source code
27.\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
28.\" 386BSD man pages
29.\" Modified Sat Jul 24 18:08:52 1993 by Rik Faith (faith@cs.unc.edu)
30.\" Modified 2001-08-31, aeb
31.\"
9ba01802 32.TH STRCMP 3 2019-03-06 "" "Linux Programmer's Manual"
fea681da
MK
33.SH NAME
34strcmp, strncmp \- compare two strings
35.SH SYNOPSIS
36.nf
37.B #include <string.h>
68e4db0a 38.PP
fea681da 39.BI "int strcmp(const char *" s1 ", const char *" s2 );
68e4db0a 40.PP
fea681da
MK
41.BI "int strncmp(const char *" s1 ", const char *" s2 ", size_t " n );
42.fi
43.SH DESCRIPTION
60a90ecd
MK
44The
45.BR strcmp ()
46d8df8e
MK
46function compares the two strings
47.I s1
48and
49.IR s2 .
cf21daa8 50The locale is not taken into account (for a locale-aware comparison, see
7e1a3cfb 51.BR strcoll (3)).
1c44bd5b 52It returns an integer less than, equal to, or greater
46d8df8e
MK
53than zero if
54.I s1
55is found, respectively, to be less than,
56to match, or be greater than
57.IR s2 .
fea681da 58.PP
60a90ecd
MK
59The
60.BR strncmp ()
33a0ccb2 61function is similar, except it compares
0647fa15 62only the first (at most)
51700fd7 63.IR n
46d8df8e
MK
64bytes of
65.I s1
66and
67.IR s2 .
47297adb 68.SH RETURN VALUE
60a90ecd
MK
69The
70.BR strcmp ()
71and
72.BR strncmp ()
73functions return an integer
46d8df8e
MK
74less than, equal to, or greater than zero if
75.I s1
76(or the first
77.I n
78bytes thereof) is found, respectively, to be less than, to
79match, or be greater than
80.IR s2 .
b5afa808 81.SH ATTRIBUTES
c091a75f
PH
82For an explanation of the terms used in this section, see
83.BR attributes (7).
84.TS
85allbox;
86lbw19 lb lb
87l l l.
88Interface Attribute Value
89T{
90.BR strcmp (),
b5afa808 91.BR strncmp ()
c091a75f
PH
92T} Thread safety MT-Safe
93.TE
47297adb 94.SH CONFORMING TO
ca362734 95POSIX.1-2001, POSIX.1-2008, C89, C99, SVr4, 4.3BSD.
47297adb 96.SH SEE ALSO
fea681da
MK
97.BR bcmp (3),
98.BR memcmp (3),
99.BR strcasecmp (3),
100.BR strcoll (3),
d095200e 101.BR string (3),
1709027c 102.BR strncasecmp (3),
a9cbb6cf 103.BR strverscmp (3),
1709027c
MK
104.BR wcscmp (3),
105.BR wcsncmp (3)