-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strdup.c
27 lines (24 loc) · 1.06 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: hnoh <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/01/04 10:29:26 by hnoh #+# #+# */
/* Updated: 2021/01/04 10:32:19 by hnoh ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strdup(const char *s)
{
char *str;
int len;
len = ft_strlen(s) + 1;
if ((str = malloc(len)))
{
ft_strlcpy(str, s, len);
return (str);
}
return (NULL);
}