/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strdup.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: scebula +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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); }