-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_striteri.c
38 lines (35 loc) · 1.32 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_striteri.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: vcodrean <vcodrean@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/30 15:58:47 by vcodrean #+# #+# */
/* Updated: 2022/10/01 10:16:47 by vcodrean ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* Apply the function f to each character of the string passed as argument,
* and passing its index as
* first argument.
*
* param char s The string to iterate through
* param void f a function that takes two parameters: an unsigned int
* and a char*
*
* return nothing.
*/
void ft_striteri(char *s, void (*f)(unsigned int, char*))
{
int i;
if (!s)
return ;
i = 0;
while (s[i] != '\0')
{
f(i, &s[i]);
i++;
}
}