-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strnew.c
33 lines (30 loc) · 1.12 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: mfrisby <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/07/11 13:18:18 by mfrisby #+# #+# */
/* Updated: 2017/07/11 13:18:19 by mfrisby ### ########.fr */
/* */
/* ************************************************************************** */
#include "libftprintf.h"
char *ft_strnew(size_t size)
{
char *str;
size_t i;
i = 0;
str = malloc(sizeof(char) * (size + 1));
if (str == NULL)
return (NULL);
else
{
while (size + 1 > i)
{
str[i] = '\0';
i++;
}
}
return (str);
}