-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathft_strmap.c
31 lines (28 loc) · 1.13 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
29
30
31
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strmap.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rlambert <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/11/05 14:44:28 by rlambert #+# #+# */
/* Updated: 2014/11/07 18:51:00 by rlambert ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include <stdlib.h>
char *ft_strmap(char const *s, char (*f)(char))
{
char *new;
unsigned int i;
new = ft_strnew(ft_strlen(s));
if (new == NULL)
return (NULL);
i = 0;
while (s[i] != '\0')
{
new[i] = f(s[i]);
i++;
}
return (new);
}