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