/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strmapi.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: madumerg +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/06 11:33:40 by madumerg #+# #+# */ /* Updated: 2023/11/08 09:42:37 by madumerg ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" char *ft_strmapi(char const *s, char (*f)(unsigned int, char)) { unsigned int i; char *str; i = 0; if (!s || !f) return (NULL); str = ft_calloc(ft_strlen(s) + 1, sizeof(char)); if (!str) return (NULL); while (s[i]) { str[i] = f(i, s[i]); i++; } return (str); }