-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strmap.c
29 lines (26 loc) · 1.12 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: nhennigh <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/02/12 17:31:56 by nhennigh #+# #+# */
/* Updated: 2019/02/14 16:15:54 by nhennigh ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strmap(char const *s, char (*f)(char))
{
char *str;
int i;
if (!s)
return (NULL);
i = -1;
str = ft_strnew(ft_strlen(s));
if (!str)
return (NULL);
while (*(s + ++i))
*(str + i) = (*f)(*(s + i));
return (str);
}