/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strmapi.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: tomoron +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/01 03:54:38 by tomoron #+# #+# */ /* Updated: 2023/11/01 14:06:34 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" char *ft_strmapi(char const *s, char (*f)(unsigned int, char)) { int i; char *res; i = 0; if (!s) return (0); res = malloc((ft_strlen(s) + 1) * sizeof(char)); if (!res) return (res); while (s[i]) { res[i] = f(i, s[i]); i++; } res[i] = 0; return (res); }