-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_lstsize.c
38 lines (34 loc) · 1.33 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
37
38
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstsize.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kczichow <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/04/11 14:25:23 by kczichow #+# #+# */
/* Updated: 2022/05/04 13:09:36 by kczichow ### ########.fr */
/* */
/* ************************************************************************** */
/* FT_LSTSIZE
* ------------
* DESCRIPTION
* Counts the number of nodes in a list, with lst: The beginning of the list.
* *lst contains the address of the head node and is therefore never
* modified; we always use a temp variable to traverse the list;
*/
#include "libft.h"
int ft_lstsize(t_list *lst)
{
int count;
t_list *temp;
count = 0;
if (lst == NULL)
return (0);
temp = lst;
while (temp)
{
temp = temp->next;
count++;
}
return (count);
}