-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_split_rev.c
39 lines (36 loc) · 1.23 KB
/
ft_split_rev.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_split_rev.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mavinici <mavinici@student.42sp.org.br> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/09 21:34:25 by mavinici #+# #+# */
/* Updated: 2022/04/21 09:31:22 by mavinici ### ########.fr */
/* */
/* ************************************************************************** */
#include <libft.h>
char *ft_split_rev(char **split)
{
char *tmp;
char *tmp2;
char *str;
int i;
if (!split)
return (NULL);
str = ft_strjoin(split[0], " ");
i = 1;
while (split[i])
{
tmp = ft_strjoin(str, split[i]);
free(str);
str = tmp;
if (split[++i])
{
tmp2 = ft_strjoin(str, " ");
free(str);
str = tmp2;
}
}
return (str);
}