-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_lstadd_back.c
57 lines (47 loc) · 1.55 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
54
55
56
57
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstadd_back.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lpicoli- < lpicoli-@student.42porto.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/18 18:09:55 by root #+# #+# */
/* Updated: 2022/11/23 09:45:04 by lpicoli- ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lstadd_back(t_list **lst, t_list *new)
{
t_list *last;
last = *lst;
if(!lst || ! new)
return ;
if (!*lst)
{
*lst = new;
return ;
}
while (last->next)
last = last->next;
last->next = new;
}
/*int main()
{
int a = 1;
int b = 2;
int c = 3;
t_list *first;
t_list *second;
t_list *third;
first = ft_lstnew(&a);
second = ft_lstnew(&b);
third = ft_lstnew(&c);
first->next = second;
second->next = NULL;
ft_lstadd_back(&first, third);
while(first)
{
printf("%d\n", *(int *)first->content);
first = first->next;
}
}*/