diff options
| author | Charles <sircharlesaze@gmail.com> | 2019-07-09 10:23:25 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2019-07-09 10:23:25 +0200 |
| commit | 2bc94312042100432ec332abd3c00104d0d095a2 (patch) | |
| tree | 6c60a0fde7b2d8bc984845f6a412171df977e1dc /c07/ex05 | |
| parent | 03b4d8a03fb1b2cf93aaac0dc9d317ff9c2ba705 (diff) | |
| download | piscine-2bc94312042100432ec332abd3c00104d0d095a2.tar.gz piscine-2bc94312042100432ec332abd3c00104d0d095a2.tar.bz2 piscine-2bc94312042100432ec332abd3c00104d0d095a2.zip | |
c07/c08 start, c05 faster, better, stronger
Diffstat (limited to 'c07/ex05')
| -rw-r--r-- | c07/ex05/ft_split.c | 49 |
1 files changed, 49 insertions, 0 deletions
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 <charles.cabergs@gmail.com> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/07/08 15:58:03 by cacharle #+# #+# */ +/* Updated: 2019/07/09 09:40:49 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include <stdlib.h> + +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); +} |
