-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strdup.c
26 lines (23 loc) · 1.1 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strdup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gantonio <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/05/21 15:52:48 by gantonio #+# #+# */
/* Updated: 2021/06/05 02:11:30 by gantonio ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strdup(char *src)
{
char *dest;
size_t len;
len = ft_strlen((char *)src);
dest = malloc(sizeof(*src) * ft_strlen(src) + 1);
if (!dest)
return (NULL);
ft_strlcpy(dest, src, len + 1);
return (dest);
}