-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_lstsize.c
36 lines (31 loc) · 1.2 KB
/
ft_lstsize.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstsize.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mmasuda <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/04/11 22:30:20 by mmasuda #+# #+# */
/* Updated: 2021/04/22 13:29:35 by mmasuda ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
static int ft_count_elem(t_list *lst, int elem_qty)
{
t_list *node;
node = lst;
while (node->next != NULL)
{
elem_qty++;
node = node->next;
}
return (elem_qty + 1);
}
int ft_lstsize(t_list *lst)
{
int elem_qty;
elem_qty = 0;
if (lst)
return (ft_count_elem(lst, elem_qty));
return (elem_qty);
}