STRNCMP - compare parts of two strings.
(ANSI Standard)
Usage:
#include <string.h>
i = strncmp( s1, s2, N );
Where:
- const char *s1, *s2;
- are the strings to be compared.
- size_t N;
- gives the number of characters to be examined.
- int i;
- gives the results of the comparison. "i" is
zero if the first N characters of the strings are
identical. "i" is positive if string
"s1" is greater than string "s2", and
is negative if string "s2" is greater than
string "s1". Comparisons of "greater
than" and "less than" are made according
to the ASCII collating sequence.
Description:
"strncmp" compares the first N characters of the
string "s1" to the first N characters of the string
"s2". If one or both of the strings is shorter than N
characters (i.e. if "strncmp" encounters a '\0'),
comparisons will stop at that point. Thus N represents the
maximum number of characters to be examined, not the exact
number. (Note that if N is zero, "strncmp" will always
return zero -- no characters are checked, so no differences are
found.)
See Also:
expl c lib memcmp
expl c lib strcmp
Copyright © 1996, Thinkage Ltd.