-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strmap.c
31 lines (28 loc) · 1.15 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: cyildiri <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/10/03 15:30:09 by cyildiri #+# #+# */
/* Updated: 2016/10/03 16:14:53 by cyildiri ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strmap(char const *s, char (*f)(char))
{
char *out;
int index;
if (s == NULL || f == NULL)
return (NULL);
if (!(out = ft_strdup(s)))
return (NULL);
index = 0;
while (s[index] != '\0')
{
out[index] = f(s[index]);
index++;
}
return (out);
}