/* ************************************************************************** */ /* */ /* :::::::: */ /* ft_strmapi.c :+: :+: */ /* +:+ */ /* By: djonker +#+ */ /* +#+ */ /* Created: 2020/11/13 03:04:33 by djonker #+# #+# */ /* Updated: 2023/10/18 17:00:19 by houtworm ######## odam.nl */ /* */ /* ************************************************************************** */ #include "../libft.h" char *ft_strmapi(char const *s, char (*f)(unsigned int, char)) { unsigned int i; char *r; i = 0; if (f == NULL || s == NULL) return (0x0); r = (char *)malloc(sizeof(char) * (ft_strlen((char *)s)) + 1); if (r == NULL) return (r); while (s[i] != '\0') { r[i] = f(i, s[i]); i++; } r[i] = '\0'; return (r); }