/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strdup.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: pbonilla +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/11/11 18:45:41 by pbonilla #+# #+# */ /* Updated: 2021/01/31 04:55:04 by pbonilla ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" char *ft_strdup(const char *s) { char *dup; int i; if (!(dup = malloc(sizeof(char) * ft_strlen(s) + 1))) return (NULL); i = -1; while (s[++i]) dup[i] = s[i]; dup[i] = 0; return (dup); }