-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strmap.c
executable file
·31 lines (28 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strmap.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: akharrou <akharrou@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/02/19 07:23:33 by akharrou #+# #+# */
/* Updated: 2019/03/04 13:17:20 by akharrou ### ########.fr */
/* */
/* ************************************************************************** */
#include "../Includes/libft.h"
char *ft_strmap(char const *s, char (*f)(char))
{
unsigned int i;
char *new_str;
if (s && *f)
{
if (!(new_str = (char *)malloc(ft_strlen(s) + 1)))
return (NULL);
i = -1;
while (s[++i])
new_str[i] = (*f)(s[i]);
new_str[i] = '\0';
return (new_str);
}
return (NULL);
}