-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strmap.c
28 lines (25 loc) · 1.16 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strmap.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: albarret <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/11/06 12:09:45 by albarret #+# #+# */
/* Updated: 2018/11/12 21:56:36 by albarret ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strmap(char const *s, char (*f)(char))
{
char *ptr;
char *ptr2;
char *result;
if (!s || !(result = ft_memalloc((size_t)ft_strlen((char*)s) + 1)))
return (NULL);
ptr = (char*)s;
ptr2 = result;
while (*ptr)
*(ptr2++) = f(*(ptr++));
return (result);
}