32 lines
1.1 KiB
C
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/08 14:06:32 by cchauvet ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "extra.h"
|
|
|
|
char *ft_strgen(char c, size_t len)
|
|
{
|
|
char *out;
|
|
size_t i;
|
|
|
|
out = malloc((len + 1) * sizeof(char));
|
|
if (out == NULL)
|
|
return (NULL);
|
|
i = 0;
|
|
while (i < len)
|
|
{
|
|
out[i] = c;
|
|
i++;
|
|
}
|
|
out[len] = '\0';
|
|
return (out);
|
|
}
|