-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strjoin.c
29 lines (26 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strjoin.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mrios-es <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/09/13 19:05:11 by mrios-es #+# #+# */
/* Updated: 2023/09/13 19:05:11 by mrios-es ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strjoin(char const *s1, char const *s2)
{
int s1_size;
int size;
char *join;
s1_size = ft_strlen(s1);
size = s1_size + ft_strlen(s2);
join = ft_calloc((size + 1), sizeof(char));
if (!join)
return (NULL);
ft_strlcat(join, s1, s1_size + 1);
ft_strlcat(join, s2, size + 1);
return (join);
}