/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_substr.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/10/17 08:28:49 by cacharle #+# #+# */ /* Updated: 2019/10/17 08:28:55 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ #include #include "libft.h" char *ft_substr(char const *s, unsigned int start, size_t len) { unsigned int i; char *sub; if (start > ft_strlen(s)) return (NULL); if ((sub = (char*)malloc(sizeof(char) * (len + 1))) == NULL) return (NULL); i = 0; while (i < len) { sub[i] = s[start + i]; i++; } sub[i] = '\0'; return (sub); }