-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strmapi.c
More file actions
32 lines (28 loc) · 1.21 KB
/
ft_strmapi.c
File metadata and controls
32 lines (28 loc) · 1.21 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_strmapi.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: csilva-s <csilva-s@student.42sp.org.br> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/07/26 14:42:49 by csilva-s #+# #+# */
/* Updated: 2025/08/15 19:09:13 by csilva-s ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
char *ft_strmapi(char const *s, char (*f)(unsigned int, char));
char *ft_strmapi(char const *s, char (*f)(unsigned int, char))
{
unsigned int i;
char *s2;
i = 0;
s2 = ft_calloc(sizeof(char), ft_strlen(s) + 1);
if (!s2)
return (NULL);
while (i < ft_strlen(s))
{
s2[i] = f(i, s[i]);
i++;
}
return (s2);
}