-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strmap.c
executable file
·35 lines (32 loc) · 1.19 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
32
33
34
35
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strmap.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aemebiku <aemebiku@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/06/26 15:42:17 by aemebiku #+# #+# */
/* Updated: 2014/06/26 15:42:18 by aemebiku ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
#include "libft.h"
char *ft_strmap(char const *s, char (*f)(char))
{
char *s2;
int i;
if (s != NULL && f != NULL)
{
i = 0;
s2 = (char *)malloc(sizeof(*s2) * ft_strlen(s));
if (s2 == NULL)
return (NULL);
while (s[i] != '\0')
{
s2[i] = f(s[i]);
i++;
}
return (s2);
}
return (0);
}