-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strnew.c
executable file
·33 lines (29 loc) · 1.2 KB
/
ft_strnew.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strnew.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ngouy <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/11/06 12:37:17 by ngouy #+# #+# */
/* Updated: 2015/11/04 17:13:49 by ngouy ### ########.fr */
/* */
/* ************************************************************************** */
/*
** Allocate memory for new str of size length and fill it with '\0'
*/
#include "libft.h"
char *ft_strnew(size_t size)
{
char *str;
size_t i;
if (size + 1 == 0)
return (NULL);
i = 0;
str = (char *)malloc(sizeof(char) * size + 1);
if (!str)
return (NULL);
while (i <= size)
str[i++] = '\0';
return (str);
}