/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strjoin.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: narnaud +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/10/20 06:49:25 by narnaud #+# #+# */ /* Updated: 2021/11/15 10:06:33 by narnaud ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" char *ft_strjoin(const char *s1, const char *s2) { char *ret; size_t i; size_t j; if (!s1 || !s2) return (NULL); ret = malloc(ft_strlen(s1) + ft_strlen(s2) + 1); if (ret == NULL) return (NULL); i = 0; while (s1[i]) { ret[i] = s1[i]; i++; } j = 0; while (s2[j]) { ret[i] = s2[j]; i++; j++; } ret[i] = '\0'; return (ret); }