-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strjoin.c
31 lines (28 loc) · 1.19 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strjoin.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gnickel <gnickel@student.42heilbronn.de> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/14 13:18:51 by gnickel #+# #+# */
/* Updated: 2024/10/14 13:18:51 by gnickel ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strjoin(const char *s1, const char *s2)
{
char *dst;
size_t s1_len;
size_t s2_len;
s1_len = ft_strlen(s1) + 1;
s2_len = ft_strlen(s2) + 1;
dst = malloc(s1_len + s2_len - 1);
if (dst)
{
ft_strlcpy(dst, s1, s1_len);
ft_strlcat(dst, s2, s1_len + s2_len);
return (dst);
}
return (0);
}