From b00680b8f649c077262ebdeb5f25e27b9acf06de Mon Sep 17 00:00:00 2001 From: Adam Joly Date: Sun, 12 Nov 2023 09:18:34 +0100 Subject: [PATCH] split norm --- ft_split.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ft_split.c b/ft_split.c index e0727d3..8f9e3e4 100644 --- a/ft_split.c +++ b/ft_split.c @@ -5,8 +5,8 @@ /* +:+ +:+ +:+ */ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ -/* Created: 2023/11/09 19:04:42 by adjoly #+# #+# */ -/* Updated: 2023/11/11 11:27:49by adjoly ### ########.fr */ +/* Created: 2023/11/12 09:14:19 by adjoly #+# #+# */ +/* Updated: 2023/11/12 09:17:04 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -60,7 +60,7 @@ char **ft_split(char const *s, char c) int i; int j; - i = 0; + i = -1; j = 0; if (s == NULL) return (NULL); @@ -68,7 +68,7 @@ char **ft_split(char const *s, char c) result = malloc((w_count + 1) * sizeof(char *)); if (result == NULL) return (ft_freearr(result)); - while (i < w_count) + while (++i < w_count) { while (s[j] == c) j++; @@ -77,7 +77,6 @@ char **ft_split(char const *s, char c) result[i] = ft_substr(s, j, ft_countletter(s + j, c)); j += ft_countletter(s + j, c); } - i++; } result[i] = NULL; return (result);