-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strmapi.c
30 lines (27 loc) · 1.13 KB
/
ft_strmapi.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strmapi.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maxweert <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/10 14:24:05 by maxweert #+# #+# */
/* Updated: 2024/10/10 14:29:49 by maxweert ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strmapi(const char *s, char (*f)(unsigned int, char))
{
size_t i;
char *ret;
i = 0;
ret = ft_calloc(ft_strlen(s) + 1, sizeof(char));
if (!ret)
return (NULL);
while (s[i])
{
ret[i] = f(i, s[i]);
i++;
}
return (ret);
}