-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_lstlast_bonus.c
More file actions
41 lines (37 loc) · 1.38 KB
/
ft_lstlast_bonus.c
File metadata and controls
41 lines (37 loc) · 1.38 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstlast_bonus.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lcosta-g <lcosta-g@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/09 13:18:50 by lcosta-g #+# #+# */
/* Updated: 2024/10/29 14:20:33 by lcosta-g ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lstlast(t_list *lst)
{
if (!lst)
return (NULL);
while (lst->next)
lst = lst->next;
return (lst);
}
/*
#include <stdio.h>
int main(void)
{
t_list *lst;
t_list *node;
t_list *new;
lst = ft_lstnew("node 1");
node = ft_lstnew("node 2");
new = ft_lstnew("ft_lstadd_back example");
ft_lstadd_back(&lst, node);
ft_lstadd_back(&lst, new);
printf("Last node Content: %s\n", (char *)ft_lstlast(lst)->content);
printf("Last node Next: %p\n", ft_lstlast(lst)->next);
return (0);
}
*/