-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strjoin.c
34 lines (31 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
28
29
30
31
32
33
34
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strjoin.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ariahi <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/16 17:57:39 by ariahi #+# #+# */
/* Updated: 2021/11/27 18:25:55 by ariahi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strjoin(const char *s1, const char *s2)
{
int len1;
int len2;
char *s;
if (!s1 || !s2)
return (NULL);
len1 = ft_strlen(s1);
len2 = ft_strlen(s2);
s = (char *)malloc(len1 + len2 + 1);
if (!s)
return (NULL);
else
{
ft_memcpy(s, s1, len1);
ft_memcpy(s + len1, s2, len2 + 1);
}
return (s);
}