/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strmapi.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/02/16 13:38:52 by fgras-ca #+# #+# */ /* Updated: 2023/11/14 17:04:43 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" char *ft_strmapi(const char *s, char (*f)(unsigned int, char)) { char *result; unsigned int i; if (!s) return (0); result = malloc(sizeof(char) * (ft_strlen(s) + 1)); if (!result) return (0); i = 0; while (s[i]) { result[i] = f(i, s[i]); i++; } result[i] = 0; return (result); }