-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strmapi.c
More file actions
36 lines (33 loc) · 1.16 KB
/
Copy pathft_strmapi.c
File metadata and controls
36 lines (33 loc) · 1.16 KB
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
31
32
33
34
35
36
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strmapi.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ekutlay <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/01/21 22:25:01 by ekutlay #+# #+# */
/* Updated: 2022/01/22 03:57:31 by ekutlay ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strmapi(char const *s, char (*f)(unsigned int, char))
{
char *ret;
unsigned int i;
if (!s || !f)
{
return ((void *)0);
}
ret = ft_strdup(s);
if (!ret)
{
return ((void *)0);
}
i = 0;
while (ret[i])
{
ret[i] = f(i, ret[i]);
i++;
}
return (ret);
}