-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strjoin.c
33 lines (29 loc) · 1.27 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strjoin.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ahmaymou <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/09 11:05:21 by ahmaymou #+# #+# */
/* Updated: 2022/11/12 21:01:13 by ahmaymou ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strjoin(char const *s1, char const *s2)
{
char *to_return;
unsigned int i;
unsigned int len;
if (!s1 || !s2)
return (NULL);
len = ft_strlen(s1) + ft_strlen(s2);
i = 0;
to_return = (char *)malloc((len + 1)
* sizeof(char));
if (!to_return)
return (NULL);
ft_strlcpy(to_return, s1, ft_strlen(s1) + 1);
ft_strlcat(to_return, s2, len + 1);
return (to_return);
}