-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_striteri.c
32 lines (30 loc) · 1.42 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_striteri.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lgasc <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/09 12:57:12 by lgasc #+# #+# */
/* Updated: 2023/02/21 18:30:57 by lgasc ### ########.fr */
/* */
/* ************************************************************************** */
/** Applies the `iterator` function on each character of the `string`
* passed as argument, passing its index as first argument.
* Each character is passed by address to the `iterator`
* function to be modified if necessary.
* @param[in,out] string The string on which to iterate.
* @param[in] iterator The function to apply to each character.
*/
void ft_striteri(char *string, void (*iterator)(unsigned int, char *))
{
unsigned int i;
if ((! string) || (! iterator))
return ;
i = 0;
while (string[i])
{
iterator(i, &string[i]);
i++;
}
}