-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strmap.c
33 lines (30 loc) · 1.16 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strmap.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dbaldy <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 13:20:15 by dbaldy #+# #+# */
/* Updated: 2015/11/30 12:04:31 by dbaldy ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include <string.h>
#include <stdlib.h>
char *ft_strmap(char const *s, char (*f)(char))
{
char *s2;
size_t i;
s2 = (char*)malloc(ft_strlen(s) + 1);
if (s2 == NULL)
return (NULL);
i = 0;
while (s[i])
{
s2[i] = (f)(s[i]);
i++;
}
s2[i] = '\0';
return (s2);
}