COHERENT manpages

This page displays the COHERENT manpage for strncmp() [Compare two strings].

List of available manpages
Index


strncmp() -- String Function (libc)

Compare two strings
#include <string.h>
int strncmp(string1, string2, n)
char *string1, *string2; unsigned n;

strncmp()  compares lexicographically  the first  n  bytes of  string1 with
string2.  Comparison  ends when  n  bytes  have been  compared,  or a  null
character encountered,  whichever occurs first.  strncmp()  returns zero if
the  strings are  identical, returns  a  number less  than zero  if string1
occurs earlier  alphabetically than string2,  and returns a  number greater
than zero if it occurs later.  This routine is compatible with the ordering
routine needed by qsort().

Example

For an example of this function, see the entry for strncpy().

See Also

libc,
strcmp(),
string.h
ANSI Standard, §7.11.4.4
POSIX Standard, §8.1