-
Notifications
You must be signed in to change notification settings - Fork 0
/
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: sael-you <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/08 15:57:26 by sael-you #+# #+# */
/* Updated: 2019/04/22 16:00:21 by sael-you ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strmap(char const *s, char (*f)(char))
{
int i;
char *tab;
i = -1;
if (!s)
return (NULL);
if (!(tab = ft_strnew(ft_strlen((char *)s))))
return (NULL);
while (s[++i])
tab[i] = f(s[i]);
return (tab);
}