-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strnew.c
30 lines (27 loc) · 1.1 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strnew.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: erli <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/11/08 09:31:42 by erli #+# #+# */
/* Updated: 2018/11/09 13:09:46 by erli ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
#include <string.h>
char *ft_strnew(size_t n)
{
char *str;
size_t i;
i = 0;
if (!(str = (char *)malloc(sizeof(char) * (n + 1))))
return (NULL);
while (i <= n)
{
str[i] = '\0';
i++;
}
return (str);
}