add libft, add gitignore

This commit is contained in:
2024-11-27 17:49:04 +01:00
parent b19228dccd
commit 3c467a5fd5
70 changed files with 2655 additions and 3 deletions

33
libft/ft_strmapi.c Executable file
View File

@ -0,0 +1,33 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strmapi.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tomoron <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/01 03:54:38 by tomoron #+# #+# */
/* Updated: 2023/11/01 14:06:34 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strmapi(char const *s, char (*f)(unsigned int, char))
{
int i;
char *res;
i = 0;
if (!s)
return (0);
res = malloc((ft_strlen(s) + 1) * sizeof(char));
if (!res)
return (res);
while (s[i])
{
res[i] = f(i, s[i]);
i++;
}
res[i] = 0;
return (res);
}