-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_lstiter.c
49 lines (41 loc) · 1.64 KB
/
ft_lstiter.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
39
40
41
42
43
44
45
46
47
48
49
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstiter.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mbrito-p <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/05/08 20:26:07 by mbrito-p #+# #+# */
/* Updated: 2023/05/08 20:26:07 by mbrito-p ### ########.fr */
/* */
/* ************************************************************************** */
// Iterates the list ’lst’ and applies the function
// ’f’ on the content of each node.
// lst: The address of a pointer to a node.
// f: The address of the function used to iterate on
// the list.
#include "libft.h"
void ft_lstiter(t_list *lst, void (*f)(void *))
{
if(!lst && !f )
return ;
while(lst)
{
f(lst->content);
lst = lst->next;
}
}
// void print_string(void *str)
// {
// printf("%s ", (char*)str);
// }
// int main()
// {
// t_list *node1 = ft_lstnew("Hello");
// t_list *node2 = ft_lstnew("world");
// t_list *node3 = ft_lstnew("!");
// node1->next = node2;
// node2->next = node3;
// ft_lstiter(node1, print_string);
// return 0;
// }