-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strjoin.c
28 lines (25 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strjoin.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mcosta-d <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/28 22:27:47 by mcosta-d #+# #+# */
/* Updated: 2023/05/09 15:33:48 by mcosta-d ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strjoin(char const *s1, char const *s2)
{
char *out;
int len;
len = ft_strlen(s1) + ft_strlen(s2);
out = (char *)malloc((len + 1) * sizeof(char));
if (out == NULL)
return (0);
ft_memcpy(out, s1, ft_strlen(s1));
ft_memcpy(out + ft_strlen(s1), s2, ft_strlen(s2));
out[len] = '\0';
return (out);
}