-
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: lpalacio <lpalacio@student.42madrid> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/03 20:54:16 by lpalacio #+# #+# */
/* Updated: 2022/10/03 20:54:25 by lpalacio ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strjoin(char const *s1, char const *s2)
{
char *str;
size_t len1;
size_t len2;
len1 = ft_strlen (s1);
len2 = ft_strlen (s2);
str = (char *)ft_calloc (len1 + len2 + 1, sizeof(char));
if (str == NULL)
return (NULL);
ft_strlcpy(str, s1, len1 + 1);
ft_strlcpy(str + len1, s2, len2 + 1);
return (str);
}