-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strmapi.c
31 lines (28 loc) · 1.17 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: sbeline <sbeline@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/11/12 15:15:28 by sbeline #+# #+# */
/* Updated: 2015/01/07 12:47:16 by sbeline ### ########.fr */
/* */
/* ************************************************************************** */
#include "Includes/libft.h"
char *ft_strmapi(char const *s, char (*f)(unsigned int, char))
{
char *str_res;
int i;
if (!s || !f)
return (NULL);
if ((str_res = ft_strdup((char*)s)) == NULL)
return (NULL);
i = 0;
while (s[i] != '\0')
{
str_res[i] = f(i, s[i]);
i++;
}
return (str_res);
}