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. 6.\" %sccs.include.redist.man% 7.\" 8.\" @(#)strcmp.3 5.5 (Berkeley) 04/19/91 9.\" 10.Dd 11.Dt STRCMP 3 12.Os 13.Sh NAME 14.Nm strcmp 15.Nd compare strings 16.Sh SYNOPSIS 17.Fd #include <string.h> 18.Ft int 19.Fn strcmp "const char *s1" "const char *s2" 20.Ft int 21.Fn strncmp "const char *s1" "const char *s2" "size_t len" 22.Sh DESCRIPTION 23The 24.Fn strcmp 25and 26.Fn strncmp 27functions 28lexicographically compare the null-terminated strings 29.Fa s1 30and 31.Fa s2 . 32.Sh RETURN VALUES 33The 34.Fn strcmp 35and 36.Fn strncmp 37return an integer greater than, equal to, or less than 0, according 38as the string 39.Fa s1 40is greater than, equal to, or less than the string 41.Fa s2 . 42The comparison is done using unsigned characters, so that 43.Ql \e200 44is greater than 45.Ql \e0 . 46.Pp 47The 48.Fn strncmp 49compares not more than 50.Fa len 51characters. 52.Sh SEE ALSO 53.Xr bcmp 3 , 54.Xr memcmp 3 , 55.Xr strcasecmp 3 , 56.Xr strcoll 3 , 57.Xr strxfrm 3 58.Sh STANDARDS 59The 60.Fn strcmp 61and 62.Fn strncmp 63functions 64conform to 65.St -ansiC . 66