-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_lstsize.c
56 lines (51 loc) · 1.66 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstsize.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ael-haib <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/07 00:29:48 by ael-haib #+# #+# */
/* Updated: 2024/02/14 01:30:44 by ael-haib ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_lstsize(t_list *lst)
{
int count;
count = 0;
while (lst != NULL)
{
lst = lst->next;
count++;
}
return (count);
}
/* int main()
{
int size;
t_list* head = NULL;
t_list* second = NULL;
t_list* third = NULL;
t_list* numberfor = NULL;
head = (t_list*)malloc(sizeof(t_list));
second = (t_list*)malloc(sizeof(t_list));
third = (t_list*)malloc(sizeof(t_list));
numberfor = (t_list*)malloc(sizeof(t_list));
head->content = (void*)1;
second->content = (void*)2;
third->content = (void*)3;
numberfor->content = (void*)5;
head->next = second;
second->next = third;
third->next = numberfor;
numberfor->next = NULL;
size = ft_lstsize(head);
printf("Size of the linked list: %d\n", size);
free(head);
free(second);
free(third);
free(numberfor);
return (0);
}
*/