32 lines
1.2 KiB
C
Executable File
32 lines
1.2 KiB
C
Executable File
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_strmapi.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: hexplor <marvin@42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2023/11/23 11:52:03 by hexplor #+# #+# */
|
|
/* Updated: 2023/11/30 09:04:01 by yantoine ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "libft.h"
|
|
|
|
char *ft_strmapi(char const *s, char (*f)(unsigned int, char))
|
|
{
|
|
unsigned int i;
|
|
char *str;
|
|
|
|
i = 0;
|
|
str = ft_calloc((ft_strlen(s) + 1), 1);
|
|
if (!str)
|
|
return (0);
|
|
while (*(s + i))
|
|
{
|
|
*(str + i) = f(i, *(s + i));
|
|
i++;
|
|
}
|
|
*(str + i) = '\0';
|
|
return (str);
|
|
}
|