-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strsplit_lst.c
42 lines (39 loc) · 1.29 KB
/
ft_strsplit_lst.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strsplit_lst.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ylagtab <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/12 16:24:42 by ylagtab #+# #+# */
/* Updated: 2019/04/20 03:11:38 by ylagtab ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_strsplit_lst(char const *s, char c)
{
t_list *head;
t_list *tmp;
char **tab;
int i;
tab = ft_strsplit(s, c);
if (tab[0] == 0)
return (NULL);
head = ft_lstnew(tab[0], ft_strlen(tab[0]));
tmp = head;
i = 1;
while (tab[i])
{
tmp->next = ft_lstnew(tab[i], ft_strlen(tab[i]));
tmp = tmp->next;
i++;
}
i = 0;
while (tab[i])
{
free(tab[i]);
i++;
}
free(tab);
return (head);
}