-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strmap.c
executable file
·31 lines (28 loc) · 1.17 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: luperez <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/11/15 18:55:24 by luperez #+# #+# */
/* Updated: 2014/12/31 17:25:46 by luperez ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strmap(char const *s, char (*f)(char))
{
int i;
char *p;
size_t len;
if (s == NULL || f == NULL)
return (NULL);
len = ft_strlen(s) + 1;
i = -1;
p = (char *)malloc(sizeof(char) * len);
ft_bzero(p, len);
while (s[++i])
p[i] = f(s[i]);
p[i] = '\0';
return (p);
}