-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_lstadd_back_bonus.c
45 lines (40 loc) · 1.42 KB
/
ft_lstadd_back_bonus.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstadd_back.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kyungkim <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/12/01 18:14:05 by kyungkim #+# #+# */
/* Updated: 2024/12/02 09:50:16 by kyungkim ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lstadd_back(t_list **lst, t_list *new)
{
t_list *lastnode;
if (!lst || !new)
return ;
if (!(*lst))
{
*lst = new;
return ;
}
lastnode = *lst;
while (lastnode->next)
lastnode = lastnode->next;
lastnode->next = new;
}
/*
int main(void)
{
t_list *test = ft_lstnew("42");
t_list **start = &test;
t_list *new = ft_lstnew("kay");
printf("%s\n", (char *)(*start)->content);
printf("%p\n", (*start)->next);
ft_lstadd_back(start, new);
printf("%s\n", (char *)(*start)->content);
printf("%p\n", (*start)->next);
}
*/