-
Notifications
You must be signed in to change notification settings - Fork 1
/
ft_lstlast.c
50 lines (42 loc) · 1.5 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstlast.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jede-ara <jede-ara@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/11 12:59:16 by jede-ara #+# #+# */
/* Updated: 2022/11/14 15:38:30 by jede-ara ### ########.fr */
/* */
/* ************************************************************************** */
/*
DESCRIÇÃO: lstlast() retorna o último elemento da lista.
*/
#include "libft.h"
t_list *ft_lstlast(t_list *lst)
{
if (!lst)
return (0);
while (lst->next)
lst = lst->next;
return (lst);
}
/*#include <stdio.h>
int main()
{
t_list *aux;
t_list *segundo;
t_list *terceiro;
t_list *quarto;
t_list *ultimo;
aux = ft_lstnew("Um");
segundo = ft_lstnew("Dois");
terceiro = ft_lstnew("Tres");
quarto = ft_lstnew("Quatro");
aux->next = segundo;
segundo->next = terceiro;
terceiro->next = quarto;
ultimo = ft_lstlast(aux);
printf("O ultimo t_list e %s e tem pointer de %p \n",
(char *)ultimo->content, ultimo->next);
}*/