-
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: bbouagou <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/02 20:00:04 by bbouagou #+# #+# */
/* Updated: 2022/10/10 15:45:21 by bbouagou ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strdup(const char *s)
{
char *copy;
copy = (char *)malloc(ft_strlen(s) + 1);
if (copy == NULL)
{
return (NULL);
}
ft_memcpy(copy, s, ft_strlen(s));
copy[ft_strlen(s)] = '\0';
return (copy);
}