-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathjoin_her.c
More file actions
36 lines (33 loc) · 1.19 KB
/
join_her.c
File metadata and controls
36 lines (33 loc) · 1.19 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* join_her.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mimeyer <mimeyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/09/16 14:06:08 by mimeyer #+# #+# */
/* Updated: 2019/09/16 15:46:46 by mimeyer ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include <stdio.h>
char *join_her(char **str, char *delim)
{
int i;
char *words;
char *s;
i = 0;
s = ft_strnew(1);
while (str[i])
{
words = ft_strjoin(s, str[i]);
free(s);
if (str[i + 1])
s = ft_strjoin(words, delim);
else
s = ft_strdup(words);
free(words);
i++;
}
return (s);
}