-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strmapi.c
31 lines (28 loc) · 1.18 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
31
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strmapi.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: chrhuang <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/11/08 09:46:27 by chrhuang #+# #+# */
/* Updated: 2018/11/08 15:23:46 by chrhuang ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strmapi(char const *s, char (*f)(unsigned int, char))
{
char *tmp;
unsigned int i;
if (s == NULL || f == NULL)
return (NULL);
i = 0;
if ((tmp = ft_strdup((char *)s)) == NULL)
return (NULL);
while (tmp[i] != '\0')
{
tmp[i] = (f)(i, tmp[i]);
i = i + 1;
}
return (tmp);
}