libft/ft_strnew.c

28 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strnew.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbrochar <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/28 18:26:56 by gbrochar #+# #+# */
/* Updated: 2015/11/29 16:25:54 by gbrochar ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strnew(size_t size)
{
char *str;
size_t i;
i = 0;
str = (char *)malloc(size * sizeof(char) + 1);
if (!str)
return (NULL);
while (i < size + 1)
str[i++] = '\0';
return (str);
}