-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strdup.c
29 lines (26 loc) · 1.14 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strdup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mbin-nas <mbin-nas@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/27 12:55:51 by mbin-nas #+# #+# */
/* Updated: 2022/07/27 15:04:33 by mbin-nas ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include <stdio.h>
char *ft_strdup(const char *src)
{
char *ptr;
size_t len;
char *dest;
ptr = (char *)src;
len = ft_strlen(ptr) + 1;
dest = malloc(len * sizeof(char));
if (!dest)
return (NULL);
ft_memcpy(dest, src, len);
return (dest);
}