-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strdup.c
35 lines (32 loc) · 1.18 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
29
30
31
32
33
34
35
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strdup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: event <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/05/15 14:37:05 by event #+# #+# */
/* Updated: 2019/06/06 15:40:30 by gwasserf ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strdup(const char *s1)
{
int len;
int index;
char *src;
char *dest;
src = (char *)s1;
len = ft_strlen(src);
index = 0;
dest = ft_strnew(len);
if (!dest)
return (NULL);
while (index < len)
{
dest[index] = s1[index];
index++;
}
dest[index] = '\0';
return (dest);
}