Files
cub3d/lib/libft/ft_strmapi.c
Angel Ortigosa Perez a4c1881930 Libft and ftprintf added
2025-11-15 10:31:47 +01:00

34 lines
1.2 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strmapi.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aortigos <aortigos@student.42malaga.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/22 16:12:53 by aortigos #+# #+# */
/* Updated: 2023/10/26 07:37:07 by aortigos ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strmapi(char const *s, char (*f) (unsigned int, char))
{
char *x;
unsigned int i;
i = 0;
if (!s)
return (NULL);
x = malloc(sizeof(char) * ft_strlen(s) + 1);
if (!(x))
return (NULL);
while (i != ft_strlen(s))
{
x[i] = (*f)(i, s[i]);
i++;
}
x[i] = '\0';
return (x);
}