-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strmap.c
31 lines (28 loc) · 1.13 KB
/
ft_strmap.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_strmap.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nromptea <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/28 00:26:44 by nromptea #+# #+# */
/* Updated: 2015/12/02 20:47:10 by nromptea ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strmap(char const *s, char (*f)(char))
{
int i;
char *res;
i = 0;
if (!s || !f)
return (NULL);
if (!(res = ft_strdup((char const*)s)))
return (NULL);
while (res[i] != '\0')
{
res[i] = f(res[i]);
i++;
}
return (res);
}