-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strmapi.c
30 lines (27 loc) · 1.12 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: isalayan <isalayan@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/18 11:16:07 by isalayan #+# #+# */
/* Updated: 2024/06/18 16:22:23 by isalayan ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strmapi(char const *s, char (*f)(unsigned int, char))
{
char *str;
unsigned int i;
str = ft_strdup(s);
if (!s || !f || !str)
return (0);
i = 0;
while (str[i])
{
str[i] = f(i, str[i]);
i++;
}
return (str);
}