-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strmap.c
More file actions
31 lines (28 loc) · 1.12 KB
/
ft_strmap.c
File metadata and controls
31 lines (28 loc) · 1.12 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strmap.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: yyefimov <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/02 15:30:42 by yyefimov #+# #+# */
/* Updated: 2016/12/12 14:31:49 by yyefimov ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strmap(char const *s, char (*f)(char))
{
char *str;
char *ptr;
if (!s || !f)
return (NULL);
str = ft_strnew(ft_strlen(s));
if (!str)
return (NULL);
ptr = str;
while (*s)
{
*str++ = f(*(s++));
}
return (ptr);
}