-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strmapi.c
30 lines (27 loc) · 1.16 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: dbrophy <dbrophy@student.42.us.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/19 12:02:05 by dbrophy #+# #+# */
/* Updated: 2020/02/19 12:02:05 by dbrophy ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include "stdlib.h"
char *ft_strmapi(const char *s, char (*f)(unsigned int, char))
{
char *out;
int i;
if (s == NULL)
return (NULL);
i = -1;
out = ft_strnew(ft_strlen(s));
if (out == NULL)
return (NULL);
while (s[++i])
out[i] = f(i, s[i]);
return (out);
}