maxishell
Implementation of a shell for Linux-like systems
Loading...
Searching...
No Matches
ft_striteri.c
Go to the documentation of this file.
1
/* ************************************************************************** */
2
/* */
3
/* ::: :::::::: */
4
/* ft_striteri.c :+: :+: :+: */
5
/* +:+ +:+ +:+ */
6
/* By: rmikhayl <rmikhayl@student.42london.c +#+ +:+ +#+ */
7
/* +#+#+#+#+#+ +#+ */
8
/* Created: 2023/12/17 17:25:28 by rmikhayl #+# #+# */
9
/* Updated: 2023/12/17 17:25:28 by rmikhayl ### ########.fr */
10
/* */
11
/* ************************************************************************** */
12
13
#include "
libft.h
"
14
15
/* *************************** ft_striteri ********************************** */
16
/* Applies a given function 'f' to each character of the string 's' */
17
/* along with its index. If 's' or 'f' is NULL, does nothing. */
18
/* */
19
/* Difference from ft_strmapi: */
20
/* - This function modifies the original string 's' in-place, while */
21
/* ft_strmapi creates a new string with the modified characters and */
22
/* returns it, leaving the original 's' unchanged. */
23
/* */
24
/* In layman's terms: It's like reading a written text and performing a */
25
/* specific action on each letter while keeping track of its position. */
26
/* ************************************************************************** */
27
28
void
ft_striteri
(
char
*s,
void
(*f)(
unsigned
int
,
char
*))
29
{
30
unsigned
int
i;
31
32
i = 0;
33
if
(!s || !f)
34
return ;
35
while
(s[i] !=
'\0'
)
36
{
37
f(i, &s[i]);
38
i++;
39
}
40
}
ft_striteri
void ft_striteri(char *s, void(*f)(unsigned int, char *))
Definition
ft_striteri.c:28
libft.h
lib
libft
src
ft_striteri.c
Generated by
1.9.8