-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strmapi.c
More file actions
35 lines (32 loc) · 1.25 KB
/
ft_strmapi.c
File metadata and controls
35 lines (32 loc) · 1.25 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
34
35
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strmapi.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: iuslu <iuslu@student.42kocaeli.com.tr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/02/04 09:21:23 by iuslu #+# #+# */
/* Updated: 2026/02/04 09:21:24 by iuslu ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
#include "libft.h"
char *ft_strmapi(char const *s, char (*f)(unsigned int, char))
{
char *newplace;
char *placestart;
unsigned int i;
i = 0;
newplace = (char *) malloc(ft_strlen(s) + 1);
if (!newplace)
return (NULL);
placestart = newplace;
while (s[i])
{
*newplace = f(i, s[i]);
i++;
newplace++;
}
*newplace = '\0';
return (placestart);
}