|
|
#include <string.h>int strncmp(const char *str1, const char *str2, size_t count);
The strncmp( ) function lexicographically compares not more than count characters from the two null-terminated strings and returns an integer based on the outcome, as shown here:
Value | Meaning |
---|---|
Less than zero | str1 is less than str2 |
Zero | str1 is equal to str2 |
Greater than zero | str1 is greater than str2 |
If there are less than count characters in either string, the comparison ends when the first null is encountered.
Related functions are strcmp( ), strnchr( ), and strncpy( ).
|
|