-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strdup.c
27 lines (24 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
27
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strdup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: omoudni <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/24 16:43:45 by omoudni #+# #+# */
/* Updated: 2021/12/02 18:48:12 by omoudni ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strdup(const char *s)
{
size_t len;
void *new;
len = ft_strlen(s);
new = (void *)malloc(len + 1);
if (!new)
return (NULL);
ft_memcpy(new, s, len);
((char *)new)[len] = '\0';
return ((char *)new);
}