42_solong/libftx/extra/ft_strgen.c
Camille Chauvet 195f7bc66a ca marche
2023-01-09 20:41:06 +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);
}