-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strmap.c
More file actions
33 lines (30 loc) · 1.17 KB
/
Copy pathft_strmap.c
File metadata and controls
33 lines (30 loc) · 1.17 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
33
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strmap.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mnishimo <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/11/26 22:31:35 by mnishimo #+# #+# */
/* Updated: 2019/01/12 22:29:10 by mnishimo ### ########.fr */
/* */
/* ************************************************************************** */
#include "libftprintf.h"
char *ft_strmap(char const *s, char (*f)(char))
{
int i;
char *ptr;
if (s == NULL)
return (NULL);
ptr = (char *)malloc(ft_strlen(s) + 1);
if (ptr == NULL)
return (NULL);
i = 0;
while (s[i] != '\0')
{
ptr[i] = f(s[i]);
i++;
}
ptr[i] = '\0';
return (ptr);
}