-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_stradd.c
38 lines (34 loc) · 1.27 KB
/
ft_stradd.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
31
32
33
34
35
36
37
38
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_stradd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sbeline <sbeline@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/03/16 15:47:33 by sbeline #+# #+# */
/* Updated: 2015/07/22 14:24:44 by sbeline ### ########.fr */
/* */
/* ************************************************************************** */
#include "Includes/libft.h"
char *ft_stradd(char **s1, char **s2)
{
char *str;
void *b;
int i;
i = ft_strlen(*s1) + ft_strlen(*s2);
if ((str = (char *)malloc(sizeof(char) * (i + 1))) == NULL)
return (NULL);
b = str;
i = 0;
while ((*s1)[i])
*str++ = (*s1)[i++];
i = 0;
while ((*s2)[i])
*str++ = (*s2)[i++];
*str = '\0';
if (*s1)
ft_strdel(s1);
if (*s2)
ft_strdel(s2);
return (b);
}