-
Notifications
You must be signed in to change notification settings - Fork 0
/
list_count.c
executable file
·49 lines (45 loc) · 1.55 KB
/
list_count.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* list_count.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: akharrou <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/02/22 19:32:18 by akharrou #+# #+# */
/* Updated: 2019/03/04 13:17:20 by akharrou ### ########.fr */
/* */
/* ************************************************************************** */
/*
** NAME
** list_count -- count the number of elements in a list.
**
** SYNOPSIS
** #include <../libft.h>
**
** unsigned int
** list_count(t_list *head);
**
** PARAMETERS
**
** t_list *head Pointer to the first element
** of a list.
**
** DESCRIPTION
** Iterates through a list counting the number of elements
** it contains, then returns the count.
**
** RETURN VALUES
** Returns the number of elements in the list.
*/
#include "../Includes/list.h"
unsigned int list_count(t_list *head)
{
unsigned int i;
i = 0;
while (head)
{
head = head->next;
++i;
}
return (i);
}