xref: /csrg-svn/lib/libc/string/strcmp.3 (revision 48351)
1*48351Scael.\" Copyright (c) 1990, 1991 The Regents of the University of California.
241969Sbostic.\" All rights reserved.
341969Sbostic.\"
441969Sbostic.\" This code is derived from software contributed to Berkeley by
541969Sbostic.\" Chris Torek.
641969Sbostic.\" %sccs.include.redist.man%
741969Sbostic.\"
8*48351Scael.\"     @(#)strcmp.3	5.5 (Berkeley) 04/19/91
941969Sbostic.\"
10*48351Scael.Dd
11*48351Scael.Dt STRCMP 3
12*48351Scael.Os
13*48351Scael.Sh NAME
14*48351Scael.Nm strcmp
15*48351Scael.Nd compare strings
16*48351Scael.Sh SYNOPSIS
17*48351Scael.Fd #include <string.h>
18*48351Scael.Ft int
19*48351Scael.Fn strcmp "const char *s1" "const char *s2"
20*48351Scael.Ft int
21*48351Scael.Fn strncmp "const char *s1" "const char *s2" "size_t len"
22*48351Scael.Sh DESCRIPTION
23*48351ScaelThe
24*48351Scael.Fn strcmp
2543631Sbosticand
26*48351Scael.Fn strncmp
27*48351Scaelfunctions
28*48351Scaellexicographically compare the null-terminated strings
29*48351Scael.Fa s1
3041969Sbosticand
31*48351Scael.Fa s2 .
32*48351Scael.Sh RETURN VALUES
33*48351ScaelThe
34*48351Scael.Fn strcmp
35*48351Scaeland
36*48351Scael.Fn strncmp
37*48351Scaelreturn an integer greater than, equal to, or less than 0, according
38*48351Scaelas the string
39*48351Scael.Fa s1
40*48351Scaelis greater than, equal to, or less than the string
41*48351Scael.Fa s2 .
42*48351ScaelThe comparison is done using unsigned characters, so that
43*48351Scael.Ql \e200
44*48351Scaelis greater than
45*48351Scael.Ql \e0 .
46*48351Scael.Pp
47*48351ScaelThe
48*48351Scael.Fn strncmp
49*48351Scaelcompares not more than
50*48351Scael.Fa len
5143627Sbosticcharacters.
52*48351Scael.Sh SEE ALSO
53*48351Scael.Xr bcmp 3 ,
54*48351Scael.Xr memcmp 3 ,
55*48351Scael.Xr strcasecmp 3 ,
56*48351Scael.Xr strcoll 3 ,
57*48351Scael.Xr strxfrm 3
58*48351Scael.Sh STANDARDS
59*48351ScaelThe
60*48351Scael.Fn strcmp
6143627Sbosticand
62*48351Scael.Fn strncmp
63*48351Scaelfunctions
64*48351Scaelconform to
65*48351Scael.St -ansiC .
66