/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strjoin.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: nalebrun +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/14 17:14:32 by nalebrun #+# #+# */ /* Updated: 2024/11/25 16:16:11 by nalebrun ### ########.fr */ /* */ /* ************************************************************************** */ #include "../../libft.h" char *ft_strjoin(const char *s1, const char *s2) { char *out; unsigned int i; unsigned int j; if (!s1 && !s2) return (NULL); if (!s1) return (ft_strdup(s2)); if (!s2) return (ft_strdup(s1)); out = ft_calloc(ft_strlen(s1) + ft_strlen(s2) + 1, sizeof(char)); if (!out) return (NULL); i = 0; j = 0; while (s1[j]) out[i++] = s1[j++]; j = 0; while (s2[j]) out[i++] = s2[j++]; return (out); }