-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strjoin.c
executable file
·29 lines (26 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
29
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strjoin.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mmasstou <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/04 16:09:07 by mmasstou #+# #+# */
/* Updated: 2021/11/14 08:16:46 by mmasstou ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strjoin(char const *s1, char const *s2)
{
char *new_string;
int len;
if (!s1)
return (0);
len = ft_strlen(s1)+ ft_strlen(s2);
new_string = (char *)malloc(len + 1);
if (!new_string)
return (NULL);
ft_strlcpy(new_string, s1, ft_strlen(s1) + 1);
ft_strlcat(new_string, s2, len + 1);
return (new_string);
}