-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathft_strjoin.c
More file actions
34 lines (31 loc) · 1.23 KB
/
ft_strjoin.c
File metadata and controls
34 lines (31 loc) · 1.23 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
30
31
32
33
34
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strjoin.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: wbeets <wbeets@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/03/20 11:57:13 by wbeets #+# #+# */
/* Updated: 2015/03/20 11:57:13 by wbeets ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strjoin(char const *s1, char const *s2)
{
int i;
int strlen;
char *tmp;
strlen = (ft_strlen((char *)s1) + ft_strlen((char *)s2) + 1);
tmp = (char *)malloc(sizeof(*tmp) * (strlen));
i = 0;
if (tmp)
{
while (*s1)
tmp[i++] = *s1++;
while (*s2)
tmp[i++] = *s2++;
tmp[i] = '\0';
return (tmp);
}
return (NULL);
}