/* ************************************************************************** */ /* */ /* ::: o_ :::::: ::: */ /* ft_strmapi.c :+: / :+::+: :+: */ /* +:+ > +:++:+ +:+ */ /* By: whaffman +#+ +:+ +#++#++:++#++ */ /* +#+ +#+#+ +#++#+ +#+ \o/ */ /* Created: 2024/10/10 17:00:30 by whaffman #+#+# #+#+# #+# #+# | */ /* Updated: 2024/10/10 17:00:30 by whaffman ### ### ### ### / \ */ /* */ /* ************************************************************************** */ #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); }