-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strmap.c
More file actions
34 lines (31 loc) · 1.18 KB
/
Copy pathft_strmap.c
File metadata and controls
34 lines (31 loc) · 1.18 KB
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: bekim <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/18 20:13:01 by bekim #+# #+# */
/* Updated: 2020/02/19 13:09:38 by bekim ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strmap(char const *s, char (*f)(char))
{
char *ret;
char *cpy_ret;
if (s == NULL || f == NULL)
return (NULL);
ret = ft_strnew(ft_strlen(s));
if (ret == NULL)
return (NULL);
cpy_ret = ret;
while (*s)
{
*ret = (*f)(*s);
ret++;
s++;
}
*ret = '\0';
return (cpy_ret);
}