-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_lstsize.c
40 lines (37 loc) · 1.34 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
39
40
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstsize.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mraineri <mraineri@student.42lisboa.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/16 16:46:14 by mraineri #+# #+# */
/* Updated: 2024/05/21 15:11:52 by mraineri ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_lstsize(t_list *lst)
{
int i;
t_list *node;
i = 0;
if (!lst)
return (0);
node = lst;
while (node->next)
{
i++;
node = node->next;
}
return (i + 1);
}
//int main(void)
//{
// t_list *node1 = ft_lstnew("Node 1");
// t_list *node2 = ft_lstnew("Node 2");
// t_list *node3 = ft_lstnew("Node 3");
// node1->next = node2;
// node2->next = node3;
// printf("\n\n\n\033[1;104m Total Of Nodes: %d \n\n\n", ft_lstsize(node1));
// return (0);
//}