-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathft_strmap.c
28 lines (25 loc) · 1.11 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: dpoveda- <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/10/21 23:40:06 by dpoveda- #+# #+# */
/* Updated: 2023/03/13 17:27:18 by dpoveda- ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft/ft_str.h"
char *ft_strmap(const char *s, char (*f)(char))
{
char *out;
if (!s || !f)
return (NULL);
out = malloc(ft_strlen(s) + 1);
if (!out)
return (NULL);
while (*s)
*out++ = f(*s++);
*out = '\0';
return (out);
}