-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_striteri.c
31 lines (28 loc) · 1.26 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_striteri.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gpiccion <gpiccion@student.42wolfsburg. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/02/12 01:06:09 by gpiccion #+# #+# */
/* Updated: 2022/02/12 01:06:09 by gpiccion ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
// Applies the function 'f' to each character of the string passed as argument,
// and passing its index as first argument.
// Each character is passed by address to 'f' to be modified if necessary.
void ft_striteri(char *s, void (*f)(unsigned int, char*))
{
size_t i;
if (s)
{
i = 0;
while (s[i])
{
f(i, &s[i]);
i++;
}
}
}