-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_lstlast.c
51 lines (48 loc) · 1.58 KB
/
ft_lstlast.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstlast.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sde-silv <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/04 13:51:29 by sde-silv #+# #+# */
/* Updated: 2023/10/04 13:51:38 by sde-silv ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lstlast(t_list *lst)
{
if (lst == 0)
return (lst);
while (lst->next != 0)
lst = lst->next;
return (lst);
}
/*
int main(void)
{
t_list *head;
t_list *current;
t_list **lst;
t_list *new;
int size;
head = 0;
head = ft_lstnew((void *)10);
//head->next = ft_lstnew((void *)20);
//new = ft_lstnew((void *)30);
*lst = head;
//new = ft_lstnew((void *)30);
//ft_lstadd_front(lst, new);
current = *lst;
size = ft_lstsize(*lst);
printf("size: %d\n", size);
while (size > 0)
{
printf("%zu\n", (size_t)current->content);
current = current->next;
size --;
}
printf("last: %zu\n", (size_t)(ft_lstlast(*lst))->content);
return (0);
}
*/