Libft
42 Libft library documentation
Loading...
Searching...
No Matches
ft_striteri.c File Reference

Go to the source code of this file.

Functions

void ft_striteri (char *s, void(*f)(unsigned int, char *))
 Applies a callback to each character of a string in place.
 

Function Documentation

◆ ft_striteri()

void ft_striteri ( char *  s,
void(*)(unsigned int, char *)  f 
)

Applies a callback to each character of a string in place.

The callback receives the character index and a pointer to the character.

Parameters
sString to modify.
fCallback applied to each character.

Definition at line 21 of file ft_striteri.c.

22{
23 unsigned int i;
24
25 if (!s || !f)
26 return ;
27 i = 0;
28 while (s[i])
29 {
30 f(i, &s[i]);
31 i++;
32 }
33}