-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_lstiter.c
56 lines (48 loc) · 1.58 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
50
51
52
53
54
55
56
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstiter.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ngtina1999 <ngtina1999@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/02 21:22:25 by thuy-ngu #+# #+# */
/* Updated: 2025/01/02 19:27:12 by ngtina1999 ### ########.fr */
/* */
/* ************************************************************************** */
#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 printing(void *data)
{
printf("%c\n", *(char *)data);
}
int main()
{
t_list *list = NULL;
char *s1 = "a";
char *s2 = "b";
char *s3 = "c";
char *s4 = "d";
t_list *n1 = ft_lstnew(s1);
t_list *n2 = ft_lstnew(s2);
t_list *n3 = ft_lstnew(s3);
t_list *n4 = ft_lstnew(s4);
list = n1;
n1->next = n2;
n2->next = n3;
n3->next = n4;
n4->next = NULL;
ft_lstiter(list, &printing);
free(list);
free(n2);
free(n3);
free(n4);
}*/