Libft aortigos

This commit is contained in:
Angel Ortigosa Perez
2025-11-15 09:18:35 +01:00
commit c87ab67280
45 changed files with 1439 additions and 0 deletions

33
ft_strmapi.c Normal file
View File

@@ -0,0 +1,33 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* 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);
}