#include "libft.h" size_t count_word(const char *p, char c) { size_t i; size_t len; i = 0; len = 0; while (p[i]) { while (p[i] == c && p[i]) i++; if (p[i] != c && p[i]) { len++; while (p[i] != c && p[i]) i++; } } return (len); } char **ft_split(char const *s, char c) { char **list; size_t i; size_t tmp; size_t hy; i = 0; hy = 0; list = (char **)malloc(sizeof(char *) * (count_word(s, c) + 1)); if (!list) return (NULL); while (s[i]) { while (s[i] && s[i] == c) i++; tmp = i; while (s[tmp] && s[tmp] != c) tmp++; if (count_word(s, c) == hy) break ; list[hy++] = ft_substr(s, i, tmp - i); i = tmp; } list[hy] = 0; return (list); }