-
Notifications
You must be signed in to change notification settings - Fork 4
/
ft_strjoin.c
27 lines (24 loc) · 1.2 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strjoin.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ykoh <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 16:31:35 by ykoh #+# #+# */
/* Updated: 2020/05/30 12:43:57 by ykoh ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strjoin(char const *s1, char const *s2)
{
size_t str_len;
char *str;
if (!s1 || !s2)
return (NULL);
str_len = ft_strlen(s1) + ft_strlen(s2);
if (!(str = malloc((str_len + 1) * sizeof(char))))
return (NULL);
ft_strlcpy(str + ft_strlcpy(str, s1, str_len + 1), s2, str_len + 1);
return (str);
}