-
Notifications
You must be signed in to change notification settings - Fork 1
/
ft_strmapi.c
29 lines (26 loc) · 1.11 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strmapi.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rde-noro <rde-noro@student.42sp.org.br> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/07 21:55:25 by rde-noro #+# #+# */
/* Updated: 2022/10/07 22:16:52 by rde-noro ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strmapi(char const *s, char (*f)(unsigned int, char))
{
unsigned int i;
char *res;
i = 0;
res = ft_calloc(ft_strlen(s) + 1, sizeof(char));
while (*s)
{
res[i] = f(i, *s);
i++;
s++;
}
return (res);
}