aboutsummaryrefslogtreecommitdiff
path: root/ft_strncmp.c
diff options
context:
space:
mode:
Diffstat (limited to 'ft_strncmp.c')
-rw-r--r--ft_strncmp.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/ft_strncmp.c b/ft_strncmp.c
index 9e5dfcd..e8188d0 100644
--- a/ft_strncmp.c
+++ b/ft_strncmp.c
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/10/07 10:27:34 by cacharle #+# #+# */
-/* Updated: 2019/10/20 13:15:38 by cacharle ### ########.fr */
+/* Updated: 2019/10/21 11:04:38 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -19,5 +19,7 @@ int ft_strncmp(const char *s1, const char *s2, size_t n)
i = 0;
while (i < n && s1[i] == s2[i] && s1[i] && s2[i])
i++;
+ if (i == n)
+ i--;
return (((unsigned char*)s1)[i] - ((unsigned char*)s2)[i]);
}