strncmp

Syntax

int strncmp(const char* s1, const char* s2, int n)

Arguments

s1
Pointer to the string to compare.
s2
Pointer to the string to which the first string is compared to.
n
The maximum number of characters to compare.

Return

An integer value indicating the result of the comparison.

Description

Compares upto the first n characters of two strings.
If a negative value is returned, string s1 is found to be less then s2. If zero is returned, both strings are identical. If a value positive and greater then zero is returned, string s1 is greater than s2.
Characters are compared by their order in the ASCII character map, this means number will be considered less then alphabetical characters, likewise capitals are considered greater than non-capitals.

Also see

strcmp