From 70a7a3a54d4e300c7ec75d18d14d6d6b174c9ee4 Mon Sep 17 00:00:00 2001 From: Charles Date: Mon, 21 Oct 2019 13:23:11 +0200 Subject: fixed strnstr, added protection on specific functions of part1 --- ft_strncmp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'ft_strncmp.c') 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 +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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]); } -- cgit