-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strdup.c
executable file
·27 lines (23 loc) · 1.13 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: ngouy <ngouy@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/11/03 12:28:07 by ngouy #+# #+# */
/* Updated: 2015/11/04 16:55:34 by ngouy ### ########.fr */
/* */
/* ************************************************************************** */
/*
** Allocate required memory and copy all bytes from s1 to the returned str
*/
#include "libft.h"
char *ft_strdup(const char *s1)
{
char *ret;
ret = (char *)malloc(sizeof(char) * ft_strlen(s1) + 1);
if (ret)
return (ft_strcpy(ret, s1));
return (NULL);
}