-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strjoin.c
More file actions
29 lines (26 loc) · 1.21 KB
/
ft_strjoin.c
File metadata and controls
29 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
29
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strjoin.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: atiampae <atiampae@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/23 21:39:58 by atiampae #+# #+# */
/* Updated: 2022/10/30 21:44:11 by atiampae ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strjoin(char const *s1, char const *s2)
{
size_t i;
char *ans;
if (!s1 || !s2)
return (NULL);
i = (size_t)ft_strlen(s1) + (size_t)ft_strlen(s2);
ans = (char *)ft_calloc(1, (i + 1));
if (!ans)
return(0);
ft_memcpy(ans, s1, ft_strlen(s1));
ft_memcpy(ans + ft_strlen(s1), s2, ft_strlen(s2));
return (ans);
}