-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strjoin.c
executable file
·33 lines (30 loc) · 1.29 KB
/
ft_strjoin.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
/* ************************************************************************** */
/* LE - / */
/* / */
/* ft_strjoin.c .:: .:/ . .:: */
/* +:+:+ +: +: +:+:+ */
/* By: brobicho <[email protected]> +:+ +: +: +:+ */
/* #+# #+ #+ #+# */
/* Created: 2017/12/04 03:19:58 by brobicho #+# ## ## #+# */
/* Updated: 2018/01/10 15:56:13 by brobicho ### #+. /#+ ###.fr */
/* / */
/* / */
/* ************************************************************************** */
#include "libft.h"
char *ft_strjoin(const char *s1, const char *s2)
{
char *res;
int i;
if (!s1 || !s2)
return (NULL);
i = ft_strlen((char*)s1) + ft_strlen((char*)s2);
if (!(res = malloc(sizeof(*res) * i + 1)))
return (NULL);
i = 0;
while (*s1)
res[i++] = *s1++;
while (*s2)
res[i++] = *s2++;
res[i] = '\0';
return (res);
}