.TH strncmp() "" "" "String Function (libc)"
.PC "Compare two strings"
.B "#include <string.h>"
\fBint strncmp(\fIstring1\^\fB, \fIstring2\^\fB, \fIn\^\fB)\fR
\fBchar *\fIstring1\^\fB, *\fIstring2\^\fB; unsigned \fIn\^\fB;\fR
.PP
.B strncmp()
compares lexicographically the first
.I n
bytes of
.I string1
with
.IR string2 .
Comparison ends when
.I n
bytes have been compared, or a null character encountered,
whichever occurs first.
.B strncmp()
returns zero if the strings are identical,
returns a number less than zero if
.I string1
occurs earlier alphabetically than
.IR string2 ,
and returns a number greater than zero if it occurs later.
This routine is compatible with the ordering routine needed by
.BR qsort() .
.SH Example
For an example of this function, see the entry for \fBstrncpy()\fR.
.SH "See Also"
.Xr "libc," libc
.Xr "strcmp()," strcmp
.Xr "string.h" string.h
.R
.br
\*(AS, \(sc7.11.4.4
.br
\*(PX Standard, \(sc8.1
