ft_strncmp
Subject
Understandable explanation
strncmp()
compares string in a lexicographic order, this means that it compares each characters by their corresponding ASCII values.
strncmp()
compares maximum n
characters in both strings.
The returned value depends on what difference is found.
If the two strings are the same, the returned result will be 0
since there is no difference.
If there is a difference, and the first different character in s2
is greater than the character at the same place in s1
, the returned result will be negative.
If there is a difference, and the first different character in s2
is less than the character at the same place in s1
, the returned result will be positive.
Hints
ft_strncmp.c
Commented solution
Last updated