30 lines
1.1 KiB
C
30 lines
1.1 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_strmapi.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2022/10/04 22:55:32 by erey-bet #+# #+# */
|
|
/* Updated: 2022/10/10 15:43:18 by erey-bet ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "libft.h"
|
|
|
|
char *ft_strmapi(char const *s, char (*f)(unsigned int, char))
|
|
{
|
|
unsigned int i;
|
|
char *str;
|
|
|
|
i = -1;
|
|
if (s == NULL || f == NULL)
|
|
return (NULL);
|
|
str = ft_strdup(s);
|
|
if (str == NULL)
|
|
return (NULL);
|
|
while (s[++i])
|
|
str[i] = f(i, s[i]);
|
|
return (str);
|
|
}
|