15static int ft_free_all(
char **arr)
25static int ft_split_count(
const char *s,
char c)
34 while (s[i] && s[i] == c)
36 while (s[i] && s[i] != c)
44static int ft_splitter(
char const *s,
char c,
char **arr,
int split_count)
54 while (arr_i < split_count)
56 while (s[i] && s[i] == c)
59 while (s[i] && s[i] != c)
62 arr[arr_i] = (
char *)malloc((size + 1) *
sizeof(char));
64 return (ft_free_all(arr));
78 split_count = ft_split_count(s, c);
79 arr = (
char **)
ft_calloc(split_count + 1,
sizeof(
char *));
82 if (!ft_splitter(s, c, arr, split_count))
char ** ft_split(char const *s, char c)
Splits string to substrings.
size_t ft_strlcpy(char *dst, const char *src, size_t dstsize)
Copies string to destination.
void * ft_calloc(size_t count, size_t size)
Allocate and zero.