/
ft_strmap.c
29 lines (26 loc) · 1.11 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strmap.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bpezeshk <bpezeshk@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/17 14:11:23 by bpezeshk #+# #+# */
/* Updated: 2017/01/19 13:11:04 by bpezeshk ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strmap(char const *s, char (*f)(char))
{
char *map;
unsigned int i;
if (!s || !f || (map = ft_strnew(ft_strlen(s))) == NULL)
return (NULL);
i = 0;
while (*s)
{
map[i++] = f(*s);
s++;
}
return (map);
}