-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strmap.c
31 lines (28 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
30
31
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strmap.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tyeung <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/10/16 19:00:52 by tyeung #+# #+# */
/* Updated: 2019/10/16 19:00:57 by tyeung ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strmap(char const *s, char (*f)(char))
{
unsigned int i;
char *out;
i = 0;
out = NULL;
if (s && f && (out = ft_strnew(ft_strlen(s))))
{
while (s[i])
{
out[i] = (*f)(s[i]);
++i;
}
}
return (out);
}