/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strjoin.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: grobledo +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/02/14 16:41:00 by grobledo #+# #+# */ /* Updated: 2023/02/14 16:41:02 by grobledo ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" char *ft_strjoin(char const *s1, char const *s2) { size_t i; size_t j; char *dest; if (!s1 || !s2) return (NULL); dest = ft_calloc ((ft_strlen(s1) + ft_strlen(s2) + 1), sizeof (char)); if (dest == 0) return (NULL); i = 0; j = 0; while (s1[i] || s2[j]) { while (i < ft_strlen(s1)) { dest[i] = s1[i]; i++; } while (j < ft_strlen(s2)) { dest[i + j] = s2[j]; j++; } } return (dest); }