-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_b.c
More file actions
executable file
·82 lines (68 loc) · 1.8 KB
/
main_b.c
File metadata and controls
executable file
·82 lines (68 loc) · 1.8 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include "libft.h"
#include <stdio.h>
void dft_lstdelone(void *uuu)
{
free(uuu);
}
void dft_lstclear(void *yyy)
{
free(yyy);
}
void dft_lstiter(void *qwe)
{
*((char *) qwe) = 'q';
}
void * fft_lstmap(void *lstt)
{
*((char *)lstt) = 'a';
return (lstt);
}
int main (void)
{
printf("ft_lstnew\n");
char *strrt = "i am the first one";
t_list *eree;
eree = ft_lstnew((void *)strrt);
printf("content : %s\n", (char *)eree->content);
printf("ft_lstadd_front\n");
t_list *one = ft_lstnew(ft_strdup("old one"));
ft_lstadd_front(&one, eree);
printf("content : %s\n", (char *)one->content);
printf("content : %s\n", (char *)one->next->content);
printf("ft_lstsize\n");
printf("%d\n", ft_lstsize(one));
printf("ft_lstlast\n");
t_list *ttr = ft_lstlast(one);
printf("%s\n", (char *)ttr->content);
printf("ft_lstadd_back\n");
t_list *yty;
yty = ft_lstnew("i will be the last node");
t_list *latt;
ft_lstadd_back(&one, yty);
latt = ft_lstlast(one);
printf("%s\n", (char *)latt->content);
printf("ft_lstdelone\n");
t_list *abc = ft_lstnew(ft_strdup("hello"));
printf("%s\n", (char *)abc->content);
ft_lstdelone(abc, dft_lstdelone);
printf("%s\n", (char *)abc->content);
printf("ft_lstclear\n");
t_list *l = ft_lstnew(ft_strdup("one"));
l->next = ft_lstnew(ft_strdup("two"));
ft_lstclear(&l, dft_lstdelone);
if(!l)
printf("Done\n");
else
printf("false\n");
printf("ft_lstiter\n");
t_list *op = ft_lstnew(ft_strdup("h"));
op->next = ft_lstnew(ft_strdup("u"));
ft_lstiter(op, dft_lstiter);
printf("%s\n%s\n", (char *)op->content, (char *)op->next->content);
printf("ft_lstmap\n");
t_list *ppo;
t_list *ow = ft_lstnew(ft_strdup("h"));
ow->next = ft_lstnew(ft_strdup("u"));
ppo = ft_lstmap(ow, fft_lstmap, dft_lstclear);
printf("%s\n%s\n", (char *)ppo->content, (char *)ppo->next->content);
}