Push libft

125/100 corrected the 14/11/23
This commit is contained in:
Raphaël 2023-11-14 13:31:56 +01:00 committed by GitHub
commit 7bd66aee5b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
45 changed files with 1462 additions and 0 deletions

34
ft_strmapi.c Normal file
View file

@ -0,0 +1,34 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strmapi.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/09 13:56:57 by rparodi #+# #+# */
/* Updated: 2023/11/13 19:49:30 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strmapi(char const *s, char (*f)(unsigned int, char))
{
size_t i;
size_t len;
char *str;
i = 0;
len = ft_strlen(s);
str = (char *)malloc(len + 1);
if (!str)
return (NULL);
else
ft_bzero((char *)str, len + 1);
while (i < len)
{
str[i] = f(i, s[i]);
i++;
}
return (str);
}