-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strmap.c
34 lines (31 loc) · 1.2 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
32
33
34
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strmap.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mschumac <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/06/12 23:30:32 by mschumac #+# #+# */
/* Updated: 2017/06/12 23:40:28 by mschumac ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strmap(char const *s, char (*f)(char))
{
char *new_string;
int s_len;
int i;
if (s == NULL)
return (NULL);
s_len = ft_strlen(s);
new_string = ft_strnew(s_len);
if (new_string == NULL)
return (NULL);
i = 0;
while (i < s_len)
{
new_string[i] = f(s[i]);
i++;
}
return (new_string);
}