42_solong/libftx/extra/ft_strmerger.c
Camille Chauvet 909bb442b6 kekw
2023-01-04 20:07:13 +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);
}