From a8f7e6e83bc4846c94c0489e0f6e0f807b35073e Mon Sep 17 00:00:00 2001 From: Thomas Vanbesien Date: Sat, 21 Feb 2026 16:29:51 +0100 Subject: Implement libft Part 2 with tests Add ft_substr, ft_strjoin, ft_strtrim, ft_split, ft_itoa, ft_strmapi, ft_striteri, ft_putchar_fd, ft_putstr_fd, ft_putendl_fd, ft_putnbr_fd. --- src/ft_strmapi.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/ft_strmapi.c (limited to 'src/ft_strmapi.c') diff --git a/src/ft_strmapi.c b/src/ft_strmapi.c new file mode 100644 index 0000000..8d419c2 --- /dev/null +++ b/src/ft_strmapi.c @@ -0,0 +1,23 @@ +#include "libft.h" +#include + +char * +ft_strmapi (char const *s, char (*f) (unsigned int, char)) +{ + size_t len; + char *result; + size_t i; + + len = ft_strlen (s); + result = malloc (len + 1); + if (!result) + return (NULL); + i = 0; + while (i < len) + { + result[i] = f (i, s[i]); + i++; + } + result[len] = '\0'; + return (result); +} -- cgit v1.2.3