-
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: tscasso <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/22 13:02:21 by tscasso #+# #+# */
/* Updated: 2023/02/22 13:02:30 by tscasso ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strjoin(char const *s1, char const *s2)
{
size_t s1_len;
size_t s2_len;
char *result;
s1_len = ft_strlen(s1);
s2_len = ft_strlen(s2);
result = (char *)malloc(s1_len + s2_len + 1);
if (result == NULL)
return (NULL);
ft_memcpy(result, s1, s1_len);
ft_memcpy(result + s1_len, s2, s2_len + 1);
return (result);
}