/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strmapi.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: pbonilla +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/11/25 17:46:08 by pbonilla #+# #+# */ /* Updated: 2021/01/31 04:53:57 by pbonilla ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" char *ft_strmapi(char const *s, char (*f)(unsigned int, char)) { char *sf; size_t i; if (!s || !f) return (NULL); if (!(sf = malloc(sizeof(char) * (ft_strlen(s) + 1)))) return (NULL); i = -1; while (s[++i]) sf[i] = (*f)(i, s[i]); sf[i] = 0; return (sf); }