-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strjoin.c
28 lines (25 loc) · 1.21 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strjoin.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: chrhuang <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/11/08 10:33:18 by chrhuang #+# #+# */
/* Updated: 2018/11/08 15:34:40 by chrhuang ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strjoin(char const *s1, char const *s2)
{
char *new;
if (s1 == NULL || s2 == NULL)
return (NULL);
if ((new = ft_strnew(ft_strlen(s1) + ft_strlen(s2) + 1)) == NULL)
return (NULL);
if ((new = ft_strcat(new, s1)) == NULL)
return (NULL);
if ((new = ft_strcat(new, s2)) == NULL)
return (NULL);
return (new);
}