-
Notifications
You must be signed in to change notification settings - Fork 1
/
ft_strnew.c
40 lines (35 loc) · 1.24 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
34
35
36
37
38
39
40
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strnew.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jony <jony@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/11/04 22:03:11 by jony #+# #+# */
/* Updated: 2019/11/04 22:03:13 by jony ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strnew(size_t size)
{
char *ptr;
unsigned char i;
ptr = (char *)malloc(sizeof(char) * size + 1);
if (!ptr)
return (NULL);
i = 0;
while (i < size)
{
ptr[i] = '\0';
i++;
}
ptr[i] = '\0';
return (ptr);
}
int main(void)
{
int size;
size = 3;
ft_strnew(3);
return (0);
}