-
Notifications
You must be signed in to change notification settings - Fork 2
/
ft_striteri.c
36 lines (32 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_striteri.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cado-car <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/07/31 11:45:49 by cado-car #+# #+# */
/* Updated: 2021/07/31 11:50:29 by cado-car ### ########lyon.fr */
/* */
/* ************************************************************************** */
/*
* DESCRIPTION
* 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.
* PARAMETERS
* #1. The string on which to iterate.
* #2. The function to apply to each character.
* RETURN VALUES
* -
*/
#include "libft.h"
void ft_striteri(char *s, void (*f)(unsigned int, char*))
{
size_t i;
if (!s || !f)
return ;
i = -1;
while (s[++i] != '\0')
(*f)(i, &s[i]);
}