-
Notifications
You must be signed in to change notification settings - Fork 0
/
list_last_item.c
executable file
·48 lines (44 loc) · 1.63 KB
/
list_last_item.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* list_last_item.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: akharrou <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/02/25 13:36:04 by akharrou #+# #+# */
/* Updated: 2019/03/04 13:17:20 by akharrou ### ########.fr */
/* */
/* ************************************************************************** */
/*
** NAME
** list_last_item -- get the last item of a list.
**
** SYNOPSIS
** #include <../libft.h>
**
** t_list *
** list_last_item(t_list *head);
**
** PARAMETERS
**
** t_list *head Pointer to the first element of
** a list.
**
** DESCRIPTION
** Traverses the list until it finds the last element of
** the list then returns a pointer to its item.
**
** RETURN VALUES
** If successful returns a pointer to the last element
** item.
*/
#include "../Includes/stdlib_42.h"
#include "../Includes/list.h"
void *list_last_item(t_list *head)
{
t_list *last_elem;
last_elem = list_last_elem(head);
if (last_elem)
return (last_elem->item);
return (NULL);
}