-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strmap.c
More file actions
32 lines (29 loc) · 1.14 KB
/
ft_strmap.c
File metadata and controls
32 lines (29 loc) · 1.14 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strmap.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lubaujar <lubaujar@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/11/09 23:17:36 by lubaujar #+# #+# */
/* Updated: 2014/11/13 14:31:57 by lubaujar ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strmap(char const *s, char (*f)(char))
{
char *str;
unsigned int i;
unsigned int len;
if (s == NULL)
return (NULL);
i = 0;
len = ft_strlen(s);
str = ft_strnew(len);
while (i < len)
{
str[i] = (*f)(s[i]);
i++;
}
return (str);
}