You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

33 lines
1.2 KiB

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strjoin.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: emartine <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/08 15:27:11 by emartine #+# #+# */
/* Updated: 2017/11/08 15:27:13 by emartine ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strjoin(char const *s1, char const *s2)
{
char *r;
char *c1;
char *c2;
size_t i;
if (!s1 || !s2 || !(r = (char *)malloc(ft_strlen(s1) + ft_strlen(s2) + 1)))
return (NULL);
c1 = (char *)s1;
c2 = (char *)s2;
i = 0;
while (*c1)
r[i++] = *(c1++);
while (*c2)
r[i++] = *(c2++);
r[i] = '\0';
return (r);
}