-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathft_strdup.c
33 lines (29 loc) · 1.25 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
30
31
32
33
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strdup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adiaz-lo <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/11/21 11:29:36 by adiaz-lo #+# #+# */
/* Updated: 2020/01/13 12:59:24 by adiaz-lo ### ########.fr */
/* */
/* ************************************************************************** */
/*
** This function returns a pointer to a new string obtained duplicating 's'.
** For further information, please check the Standard C Library
** strdup(const char *s)
*/
#include "libft.h"
char *ft_strdup(const char *s)
{
char *str;
int str_len;
str_len = ft_strlen(s) + 1;
if ((str = malloc(str_len)))
{
ft_strlcpy(str, s, str_len);
return (str);
}
return (NULL);
}