-
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: lubaujar <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/11/11 15:19:04 by lubaujar #+# #+# */
/* Updated: 2014/11/13 14:31:40 by lubaujar ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strjoin(char const *s1, char const *s2)
{
char *str;
int len;
if (s1 == NULL || s2 == NULL)
return (NULL);
len = ft_strlen(s1) + ft_strlen(s2);
str = (char *)malloc(sizeof(char *) * len + 1);
if (str == NULL)
return (NULL);
ft_strcpy(str, s1);
ft_strcat(str, s2);
return (str);
}