-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_lstsize.c
34 lines (30 loc) · 1.23 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstsize.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gcosta-d <gcosta-d@student.42sp.org.br> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/09/09 12:22:18 by gcosta-d #+# #+# */
/* Updated: 2021/09/14 10:53:48 by gcosta-d ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/* This function return how many elements are linked.
* While next point to an element, we passed to that element
* and count plus one. We initiate i with 1 because we need
* to count at least one element.
*/
int ft_lstsize(t_list *lst)
{
int i;
i = 1;
if (!lst)
return (0);
while (lst->next)
{
lst = lst->next;
i++;
}
return (i);
}