-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strnew.c
31 lines (28 loc) · 1.09 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strnew.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: igarbuz <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/11/08 19:34:15 by igarbuz #+# #+# */
/* Updated: 2018/11/08 19:47:23 by igarbuz ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strnew(size_t size)
{
char *s;
char *ptr;
if (!(s = (char *)malloc(size + 1)))
return (NULL);
ptr = s;
while (size)
{
*ptr = '\0';
ptr++;
size--;
}
*ptr = '\0';
return (s);
}