From 2bc94312042100432ec332abd3c00104d0d095a2 Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 9 Jul 2019 10:23:25 +0200 Subject: c07/c08 start, c05 faster, better, stronger --- c07/ex05/ft_split.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 c07/ex05/ft_split.c (limited to 'c07/ex05/ft_split.c') diff --git a/c07/ex05/ft_split.c b/c07/ex05/ft_split.c new file mode 100644 index 0000000..da2d7fc --- /dev/null +++ b/c07/ex05/ft_split.c @@ -0,0 +1,49 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_split.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/07/08 15:58:03 by cacharle #+# #+# */ +/* Updated: 2019/07/09 09:40:49 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +int count_segment(char *str, char *charset) +{ + int counter; + int i; + + counter = 0; + while (*str) + { + i = 0; + while (charset[i]) + if (str++ == charset[i++]) + counter++; + str++; + } + return (counter); +} + +int strlen_until_sep(char *str, char *charset) +{ + +} + +char **ft_split(char *str, char *charset) +{ + char **strs; + + strs = (char**)malloc(sizeof(char*) * count_segment(str, charset)); + printf("%d\n", count_segment(str, charset)); + /*while (*str)*/ + /*{*/ + + /*str++;*/ + /*}*/ + return (strs); +} -- cgit