libftx/extra/ft_strmerger.c
Camille Chauvet fcbe35befd kekw
2023-01-19 17:33:26 +01:00

34 lines
1.2 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strmerger.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/04 15:09:15 by cchauvet #+# #+# */
/* Updated: 2023/01/04 15:24:17 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "extra.h"
char *ft_strmerger(size_t arg_len, ...)
{
va_list va;
char *out;
char *temp;
va_start(va, arg_len);
out = ft_strjoin(va_arg(va, char *), va_arg(va, char *));
while (arg_len > 2)
{
temp = ft_strjoin(out, va_arg(va, char *));
free(out);
if (temp == NULL)
return (NULL);
out = temp;
arg_len--;
}
return (out);
}