/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strmapi.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: vvobis +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/04/07 17:01:35 by vvobis #+# #+# */ /* Updated: 2024/04/12 10:13:57 by vvobis ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" char *ft_strmapi(char const *s, char (*f)(unsigned int, char)) { char *tmp; unsigned int i; if (!s || !f) return (NULL); tmp = ft_calloc(ft_strlen(s) + 1, sizeof(*tmp)); if (!tmp) return (NULL); i = 0; while (s[i]) { tmp[i] = f(i, s[i]); i++; } tmp[i] = 0; return (tmp); }