/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strmap.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: hulamy +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2018/11/14 21:17:49 by hulamy #+# #+# */ /* Updated: 2019/03/25 15:23:12 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ /* ** create a new array with the result of function f on every element of s */ #include "libft.h" char *ft_strmap(char const *s, char (*f)(char)) { char *str; int i; if (!s) return (NULL); if (!(str = ft_strnew(ft_strlen(s)))) return (NULL); i = -1; while (s[++i]) str[i] = f(s[i]); return (str); }