-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathft_strmapi.c
More file actions
46 lines (40 loc) · 1.33 KB
/
ft_strmapi.c
File metadata and controls
46 lines (40 loc) · 1.33 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
36
37
38
39
40
41
42
43
44
45
46
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strmapi.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jperpect <jperpect@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/17 17:08:57 by jperpect #+# #+# */
/* Updated: 2024/04/30 12:31:54 by jperpect ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strmapi(char const *s, char (*f)(unsigned int, char))
{
char *st;
unsigned int i;
st = ft_calloc(ft_strlen(s) + 1, sizeof(char));
if (st == NULL)
return (NULL);
i = 0;
while (i < ft_strlen(s))
{
st[i] = f(i, s[i]);
i++;
}
st[i] = '\0';
return (st);
}
/*
char rs( unsigned int i,char c)
{
if (c >= 'a' && c <= 'z')
c -=32;
return(c);
}
int main(int ac , char **av)
{
printf("%s",ft_strmapi(av[1],rs));
}
*/