-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strmapi.c
More file actions
31 lines (28 loc) · 1.16 KB
/
ft_strmapi.c
File metadata and controls
31 lines (28 loc) · 1.16 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strmapi.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lbiasuz <lbiasuz@student.42sp.org.br> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/04/23 09:33:38 by lbiasuz #+# #+# */
/* Updated: 2022/04/23 09:48:19 by lbiasuz ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strmapi(char const *s, char (*f)(unsigned int, char))
{
char *dest;
unsigned int i;
i = 0;
dest = ft_calloc(ft_strlen(s) + 1, sizeof(char));
if (!dest)
return (NULL);
while (s[i])
{
dest[i] = f(i, s[i]);
i++;
}
dest[i] = '\0';
return (dest);
}