-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strmapi orig.c
More file actions
30 lines (27 loc) · 1.15 KB
/
ft_strmapi orig.c
File metadata and controls
30 lines (27 loc) · 1.15 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strmapi.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fsanz-ex <fsanz-ex@student.42madrid.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/04 22:04:13 by fsanz-ex #+# #+# */
/* Updated: 2023/05/11 15:13:48 by fsanz-ex ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strmapi(char const *s, char (*f)(unsigned int, char))
{
unsigned int i;
char *str;
if (s == NULL || f == NULL)
return (NULL);
str = (char *) s;
i = 0;
while (str[i])
{
str[i] = (*f)(i, str[i]);
i++;
}
return (ft_strdup((const char *) str));
}