Libft
42 Libft library documentation
Loading...
Searching...
No Matches
ft_lstlast.c File Reference
#include <stdlib.h>
#include "../includes/types.h"
+ Include dependency graph for ft_lstlast.c:

Go to the source code of this file.

Functions

t_listft_lstlast (t_list *lst)
 Returns the last element of a linked list. This function takes a linked list and returns a pointer to the last element.
 

Function Documentation

◆ ft_lstlast()

t_list * ft_lstlast ( t_list lst)

Returns the last element of a linked list. This function takes a linked list and returns a pointer to the last element.

Parameters
lstThe linked list to search.
Returns
A pointer to the last element of the list, or NULL if the list is empty.

Definition at line 23 of file ft_lstlast.c.

24{
25 if (!lst)
26 return (NULL);
27 while (lst->next)
28 lst = lst->next;
29 return (lst);
30}
struct s_list * next
Definition types.h:6

References s_list::next.

Referenced by ft_lstadd_back().

+ Here is the caller graph for this function: