split norm
This commit is contained in:
@ -5,8 +5,8 @@
|
|||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/09 19:04:42 by adjoly #+# #+# */
|
/* Created: 2023/11/12 09:14:19 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/11 11:27:49by adjoly ### ########.fr */
|
/* 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 i;
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
i = 0;
|
i = -1;
|
||||||
j = 0;
|
j = 0;
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
@ -68,7 +68,7 @@ char **ft_split(char const *s, char c)
|
|||||||
result = malloc((w_count + 1) * sizeof(char *));
|
result = malloc((w_count + 1) * sizeof(char *));
|
||||||
if (result == NULL)
|
if (result == NULL)
|
||||||
return (ft_freearr(result));
|
return (ft_freearr(result));
|
||||||
while (i < w_count)
|
while (++i < w_count)
|
||||||
{
|
{
|
||||||
while (s[j] == c)
|
while (s[j] == c)
|
||||||
j++;
|
j++;
|
||||||
@ -77,7 +77,6 @@ char **ft_split(char const *s, char c)
|
|||||||
result[i] = ft_substr(s, j, ft_countletter(s + j, c));
|
result[i] = ft_substr(s, j, ft_countletter(s + j, c));
|
||||||
j += ft_countletter(s + j, c);
|
j += ft_countletter(s + j, c);
|
||||||
}
|
}
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
result[i] = NULL;
|
result[i] = NULL;
|
||||||
return (result);
|
return (result);
|
||||||
|
Reference in New Issue
Block a user