-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strdup.c
28 lines (25 loc) · 1.12 KB
/
ft_strdup.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strdup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: knzeng-e <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/03/21 04:42:42 by knzeng-e #+# #+# */
/* Updated: 2016/03/23 00:47:06 by knzeng-e ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strdup(const char *s1)
{
char *out;
int i;
out = (char *)malloc(sizeof(char) * ft_strlen(s1) + 1);
i = -1;
if (out == NULL || s1 == NULL)
return (NULL);
while (s1[++i])
out[i] = s1[i];
out[i] = '\0';
return (out);
}