-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strjoin.c
30 lines (27 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
29
30
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strjoin.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ychahbar <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/06/26 15:07:35 by ychahbar #+# #+# */
/* Updated: 2018/07/05 14:23:37 by ychahbar ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strjoin(char const *s1, char const *s2)
{
size_t i;
size_t j;
char *str;
if ((s1 == NULL) || (s2 == NULL))
return (NULL);
i = ft_strlen(s1);
j = ft_strlen(s2);
if (!(str = (char *)malloc(sizeof(char) * (i + j + 1))))
return (NULL);
ft_strcpy(str, s1);
ft_strcat(str, s2);
return (str);
}