-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strdup.c
executable file
·26 lines (23 loc) · 1.11 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strdup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mberger <mberger@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/11/06 17:51:00 by mberger #+# #+# */
/* Updated: 2015/03/22 00:10:35 by mberger ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strdup(const char *s1)
{
char *scopy;
size_t len;
len = ft_strlen(s1);
scopy = (char*)malloc(sizeof(char*) * len);
if (scopy == NULL)
return (NULL);
scopy = ft_strncpy(scopy, s1, len);
return (scopy);
}