36 lines
1.2 KiB
C
36 lines
1.2 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_strdup.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2015/11/24 20:46:25 by scebula #+# #+# */
|
|
/* Updated: 2015/12/04 00:28:12 by scebula ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "libft.h"
|
|
|
|
char *ft_strdup(const char *s1)
|
|
{
|
|
int l;
|
|
int i;
|
|
char *str;
|
|
|
|
i = 0;
|
|
if (!s1)
|
|
return (NULL);
|
|
l = ft_strlen(s1);
|
|
str = (char *)malloc(sizeof(char) * (l + 1));
|
|
if (str == NULL)
|
|
return (NULL);
|
|
while (i < l)
|
|
{
|
|
str[i] = s1[i];
|
|
i++;
|
|
}
|
|
str[i] = '\0';
|
|
return (str);
|
|
}
|