-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strjoin.c
More file actions
28 lines (26 loc) · 1.21 KB
/
ft_strjoin.c
File metadata and controls
28 lines (26 loc) · 1.21 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strjoin.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nle-roux <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/01 16:36:17 by nle-roux #+# #+# */
/* Updated: 2023/11/11 19:16:05 by nle-roux ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strjoin(const char *s1, const char *s2)
{
char *res;
size_t tot_len;
if (!s1 || !s2)
return (NULL);
tot_len = ft_strlen(s1) + ft_strlen(s2);
res = (char *)ft_calloc((tot_len + 1), sizeof(char));
if (!res)
return (NULL);
ft_strlcat(res, s1, tot_len + 1);
ft_strlcat(res, s2, tot_len + 1);
return (res);
}