-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strdup.c
28 lines (25 loc) · 1.11 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: ahmaymou <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/08 14:40:49 by ahmaymou #+# #+# */
/* Updated: 2022/11/12 15:52:52 by ahmaymou ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strdup(const char *s1)
{
char *copy;
int len;
int i;
len = ft_strlen(s1);
i = 0;
copy = (char *)malloc((len + 1) * sizeof(char));
if (!copy)
return (NULL);
ft_strlcpy(copy, s1, len + 1);
return (copy);
}