-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_wcstrjoin.c
40 lines (37 loc) · 1.28 KB
/
ft_wcstrjoin.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_wcstrjoin.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tmaraval <tmaraval@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/01/17 08:38:34 by tmaraval #+# #+# */
/* Updated: 2018/01/24 08:20:55 by tmaraval ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
wchar_t *ft_wcstrjoin(wchar_t const *s1, wchar_t const *s2)
{
wchar_t *ret;
int i;
int j;
i = 0;
j = 0;
if (s1 == NULL || s2 == NULL)
return (NULL);
if ((ret =
malloc(sizeof(wchar_t) * (ft_wcstrlen(s1) + ft_wcstrlen(s2) + 1))) == NULL)
return (NULL);
while (s1[i])
{
ret[i] = s1[i];
i++;
}
while (s2[j])
{
ret[i + j] = s2[j];
j++;
}
ret[i + j] = '\0';
return (ret);
}