-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_lstadd_back.c
53 lines (49 loc) · 1.6 KB
/
ft_lstadd_back.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstadd_back.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sde-silv <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/04 13:51:53 by sde-silv #+# #+# */
/* Updated: 2023/10/04 13:52:04 by sde-silv ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lstadd_back(t_list **lst, t_list *new)
{
t_list *temp;
if (*lst == 0)
*lst = new;
else
{
temp = *lst;
while (temp->next != 0)
temp = temp->next;
temp->next = new;
}
}
/*
int main(void)
{
t_list *head;
t_list *current;
t_list **lst;
int size;
head = ft_lstnew((void *)20);
head->next = ft_lstnew((void *)30);
*lst = head;
ft_lstadd_front(lst, ft_lstnew((void *)10));
ft_lstadd_back(lst, ft_lstnew((void *)40));
current = *lst;
size = ft_lstsize(*lst);
printf("size: %d\n", size);
while (current != NULL)
{
printf("%zu\n", (size_t)current->content);
current = current->next;
}
printf("last: %zu\n", (size_t)(ft_lstlast(*lst))->content);
return (0);
}
*/