-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strmap.c
More file actions
executable file
·29 lines (26 loc) · 1.15 KB
/
Copy pathft_strmap.c
File metadata and controls
executable file
·29 lines (26 loc) · 1.15 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strmap.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: patrisor <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/02/26 16:44:09 by patrisor #+# #+# */
/* Updated: 2019/03/09 16:54:32 by patrisor ### ########.fr */
/* */
/* ************************************************************************** */
#include "includes/libft.h"
char *ft_strmap(char const *s, char (*f)(char))
{
char *new_str;
int i;
if (!s)
return (NULL);
new_str = ft_strnew(ft_strlen(s));
if (!new_str)
return (NULL);
i = -1;
while (*(s + ++i))
*(new_str + i) = f(*(s + i));
return (new_str);
}