-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_ft_lstsize.c
53 lines (49 loc) · 1.63 KB
/
test_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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* test_ft_lstsize.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jliew <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/07/06 19:46:33 by jliew #+# #+# */
/* Updated: 2020/07/09 23:20:28 by jliew ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include <string.h>
#include "libft.h"
void print_list(t_list *list)
{
while (list)
{
printf("[%s]", list->content);
printf("%s", ((list->next) ? " -> " : "\n"));
list = list->next;
}
}
int main(int argc, char **argv)
{
int i;
int size;
t_list *list;
if (argc == 1)
{
printf("-----------------------------\n");
printf(" int ft_lstsize(t_list *lst)\n");
printf("-----------------------------\n");
printf("usage [manual]:\n");
printf("1. a --list <. . .>\n");
return (42);
}
else if (!strcmp(argv[1], "--list"))
{
i = 2;
list = NULL;
while (i < argc)
ft_lstadd_back(&list, ft_lstnew(strdup(argv[i++])));
print_list(list);
size = ft_lstsize(list);
printf("size: %d\n", size);
ft_lstclear(&list, free);
}
}