libftx/extra/ft_strgen.c

32 lines
1.1 KiB
C
Raw Permalink Normal View History

2023-01-19 11:33:26 -05:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* 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);
}