-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_striteri.c
45 lines (41 loc) · 1.36 KB
/
ft_striteri.c
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_striteri.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rgerdzhi <[email protected] +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/14 01:13:56 by rgerdzhi #+# #+# */
/* Updated: 2024/08/07 16:16:46 by rgerdzhi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_striteri(char *s, void (*f)(unsigned int, char*))
{
unsigned int i;
if (!s)
return ;
i = 0;
while (s[i])
{
(*f)(i, &s[i]);
i++;
}
}
/*
void to_func(unsigned int i, char *c)
{
(void)i;
if (ft_isdigit(*c))
*c = '@';
else if (ft_isalpha(*c))
*c = ft_toupper(*c);
}
int main(void)
{
char str[] = "hello world1234687&&*";
printf("Original string: %s\n", str);
ft_striteri(str, to_func);
printf("Modified string: %s\n", str);
return (0);
}*/