xref: /csrg-svn/lib/libc/string/strcmp.3 (revision 61193)
1*61193Sbostic.\" Copyright (c) 1990, 1991, 1993
2*61193Sbostic.\"	The Regents of the University of California.  All rights reserved.
341969Sbostic.\"
441969Sbostic.\" This code is derived from software contributed to Berkeley by
550321Sbostic.\" Chris Torek and the American National Standards Committee X3,
650321Sbostic.\" on Information Processing Systems.
750321Sbostic.\"
841969Sbostic.\" %sccs.include.redist.man%
941969Sbostic.\"
10*61193Sbostic.\"     @(#)strcmp.3	8.1 (Berkeley) 06/04/93
1141969Sbostic.\"
1248351Scael.Dd
1348351Scael.Dt STRCMP 3
1448351Scael.Os
1548351Scael.Sh NAME
1648351Scael.Nm strcmp
1748351Scael.Nd compare strings
1848351Scael.Sh SYNOPSIS
1948351Scael.Fd #include <string.h>
2048351Scael.Ft int
2148351Scael.Fn strcmp "const char *s1" "const char *s2"
2248351Scael.Ft int
2348351Scael.Fn strncmp "const char *s1" "const char *s2" "size_t len"
2448351Scael.Sh DESCRIPTION
2548351ScaelThe
2648351Scael.Fn strcmp
2743631Sbosticand
2848351Scael.Fn strncmp
2948351Scaelfunctions
3048351Scaellexicographically compare the null-terminated strings
3148351Scael.Fa s1
3241969Sbosticand
3348351Scael.Fa s2 .
3448351Scael.Sh RETURN VALUES
3548351ScaelThe
3648351Scael.Fn strcmp
3748351Scaeland
3848351Scael.Fn strncmp
3948351Scaelreturn an integer greater than, equal to, or less than 0, according
4048351Scaelas the string
4148351Scael.Fa s1
4248351Scaelis greater than, equal to, or less than the string
4348351Scael.Fa s2 .
4448351ScaelThe comparison is done using unsigned characters, so that
4548351Scael.Ql \e200
4648351Scaelis greater than
4748351Scael.Ql \e0 .
4848351Scael.Pp
4948351ScaelThe
5048351Scael.Fn strncmp
5148351Scaelcompares not more than
5248351Scael.Fa len
5343627Sbosticcharacters.
5448351Scael.Sh SEE ALSO
5548351Scael.Xr bcmp 3 ,
5648351Scael.Xr memcmp 3 ,
5748351Scael.Xr strcasecmp 3 ,
5848351Scael.Xr strcoll 3 ,
5948351Scael.Xr strxfrm 3
6048351Scael.Sh STANDARDS
6148351ScaelThe
6248351Scael.Fn strcmp
6343627Sbosticand
6448351Scael.Fn strncmp
6548351Scaelfunctions
6648351Scaelconform to
6748351Scael.St -ansiC .
68