/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strmapi.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: whaffman +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/07/05 18:42:10 by whaffman #+# #+# */ /* Updated: 2024/07/10 16:06:40 by whaffman ### ########.fr */ /* */ /* ************************************************************************** */ #include #include "libft.h" char *ft_strmapi(char const *s, char (*f)(unsigned int, char)) { int i; char *result; if (!s) return (NULL); result = malloc((ft_strlen(s) + 1) * sizeof(char)); if (!result) return (NULL); i = 0; while (s[i]) { result[i] = f(i, s[i]); i++; } result[i] = '\0'; return (result); }