-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strjoin.c
34 lines (31 loc) · 1.22 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: emdi-mar <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/08 21:51:29 by emdi-mar #+# #+# */
/* Updated: 2024/11/08 21:52:59 by emdi-mar ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strjoin(char const *s1, char const *s2)
{
char *p;
size_t len_s1;
size_t len_s2;
p = NULL;
if (s1 && s2)
{
len_s1 = ft_strlen(s1);
len_s2 = ft_strlen(s2);
p = ft_calloc(len_s1 + len_s2 + 1, sizeof(*p));
if (p)
{
ft_strlcat(p, s1, len_s1 + 1);
ft_strlcat(p, s2, len_s1 + 1 + len_s2 + 1);
}
}
return (p);
}