/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strdup.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: tmaze +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2018/04/03 16:33:35 by tmaze #+# #+# */ /* Updated: 2018/04/04 15:29:36 by tmaze ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" char *ft_strdup(const char *s1) { int i; char *ret; i = 0; while (s1[i]) i++; if ((ret = (char*)malloc(sizeof(char) * (i + 1))) != NULL) { ret[i] = '\0'; i = -1; while (s1[++i]) ret[i] = s1[i]; } return (ret); }