-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_lstiter.c
63 lines (57 loc) · 1.65 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
57
58
59
60
61
62
63
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstiter.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tiagalex <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/12 11:57:10 by tiagalex #+# #+# */
/* Updated: 2024/11/12 14:12:10 by tiagalex ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lstiter(t_list *lst, void (*f)(void *))
{
if (!lst)
return ;
while (lst)
{
(*f)(lst->content);
lst = lst->next;
}
}
/*
void uppercase(void *str)
{
int i;
char *temp;
i = 0;
temp = (char *)str;
while (temp[i] != '\0')
{
if (temp[i] >= 'a' && temp[i] <= 'z')
temp[i] = temp[i] - 32;
i++;
}
}
int main()
{
t_list *lst = ft_lstnew(ft_strdup("Uva\n"));
ft_lstadd_back(&lst,ft_lstnew(ft_strdup("MANGA\n")));
ft_lstadd_back(&lst,ft_lstnew(ft_strdup("aNAnas123\n")));
t_list *temp = lst;
printf ("\nOriginal\n");
while (temp)
{
printf("%s", (char *)temp->content);
temp = temp->next;
}
ft_lstiter(lst, uppercase);
printf ("\nAfter change\n");
while (lst)
{
printf("%s", (char *)lst->content);
lst = lst->next;
}
return (0);
} */