-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strdup.c
26 lines (23 loc) · 1.09 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: thakala <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/06 13:39:27 by thakala #+# #+# */
/* Updated: 2021/11/21 18:27:16 by thakala ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include <stdlib.h>
char *ft_strdup(const char *s1)
{
size_t len;
char *dup;
len = ft_strlen(s1) + 1;
dup = (char *)malloc(sizeof(char) * len);
if (dup)
ft_memcpy(dup, s1, len);
return (dup);
}