42_minishell/libftx/extra/ft_strgen.c
Camille Chauvet 5a102e93a1 init
2023-01-31 14:40:15 +01:00

32 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strgen.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/08 12:32:52 by cchauvet #+# #+# */
/* Updated: 2023/01/09 18:04:31 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "extra.h"
char *ft_strgen(char c, size_t len)
{
char *out;
size_t i;
out = ft_calloc((len + 1), sizeof(char));
if (out == NULL)
return (NULL);
i = 0;
while (i < len)
{
out[i] = c;
i++;
}
out[len] = '\0';
return (out);
}