-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strmapi.c
29 lines (26 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strmapi.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rvandepu <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/20 16:38:44 by rvandepu #+# #+# */
/* Updated: 2023/10/20 16:42:44 by rvandepu ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
#include "libft.h"
char *ft_strmapi(char const *s, char (*f)(unsigned int, char))
{
char *r;
int i;
r = malloc(ft_strlen(s) + 1);
if (r == NULL)
return (r);
i = -1;
while (s[++i])
r[i] = f(i, s[i]);
r[i] = '\0';
return (r);
}