Libft and ftprintf added

This commit is contained in:
Angel Ortigosa Perez
2025-11-15 10:31:47 +01:00
parent 5c40a00540
commit a4c1881930
54 changed files with 1809 additions and 105 deletions

33
lib/libft/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);
}