-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strjoin.c
29 lines (26 loc) · 1.19 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: lenzo-pe <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/02/13 19:07:59 by lenzo-pe #+# #+# */
/* Updated: 2021/06/08 19:01:42 by lenzo-pe ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_string.h"
char *ft_strjoin(char const *s1, char const *s2)
{
char *ptr;
size_t total_len;
if (!s1 || !s2)
return (NULL);
total_len = ft_strlen(s1) + ft_strlen(s2);
ptr = (char *)malloc(sizeof(char) * (total_len + 1));
if (!ptr)
return (NULL);
ft_strcpy(ptr, s1);
ft_strcat(ptr, s2);
return (ptr);
}