xref: /original-bsd/lib/libc/string/strcmp.3 (revision b5ed8b48)
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek and the American National Standards Committee X3,
6.\" on Information Processing Systems.
7.\"
8.\" %sccs.include.redist.man%
9.\"
10.\"     @(#)strcmp.3	5.6 (Berkeley) 06/29/91
11.\"
12.Dd
13.Dt STRCMP 3
14.Os
15.Sh NAME
16.Nm strcmp
17.Nd compare strings
18.Sh SYNOPSIS
19.Fd #include <string.h>
20.Ft int
21.Fn strcmp "const char *s1" "const char *s2"
22.Ft int
23.Fn strncmp "const char *s1" "const char *s2" "size_t len"
24.Sh DESCRIPTION
25The
26.Fn strcmp
27and
28.Fn strncmp
29functions
30lexicographically compare the null-terminated strings
31.Fa s1
32and
33.Fa s2 .
34.Sh RETURN VALUES
35The
36.Fn strcmp
37and
38.Fn strncmp
39return an integer greater than, equal to, or less than 0, according
40as the string
41.Fa s1
42is greater than, equal to, or less than the string
43.Fa s2 .
44The comparison is done using unsigned characters, so that
45.Ql \e200
46is greater than
47.Ql \e0 .
48.Pp
49The
50.Fn strncmp
51compares not more than
52.Fa len
53characters.
54.Sh SEE ALSO
55.Xr bcmp 3 ,
56.Xr memcmp 3 ,
57.Xr strcasecmp 3 ,
58.Xr strcoll 3 ,
59.Xr strxfrm 3
60.Sh STANDARDS
61The
62.Fn strcmp
63and
64.Fn strncmp
65functions
66conform to
67.St -ansiC .
68