-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_striteri.c
52 lines (42 loc) · 1.38 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
46
47
48
49
50
51
52
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_striteri.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: snocita <snocita@student.42wolfsburg.de> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/20 11:15:33 by snocita #+# #+# */
/* Updated: 2023/01/07 14:16:43 by snocita ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/*
takes a string, and a function.
applies the function in each
character in the string.
*/
// void print(unsigned int i, char *s)
// {
// printf("%c", s[i]);
// }
// void iter(unsigned int i, char *s)
// {
// *s += i;
// }
void ft_striteri(char *s, void (*f)(unsigned int, char *))
{
unsigned int index;
if (!s || !f)
return ;
index = 0;
while (s[index])
{
f(index, s + index);
index++;
}
}
// int main(void)
// {
// char str[] = "0000000000";
// ft_striteri(str, iter);
// }