-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_lstadd_back.c
41 lines (36 loc) · 1.34 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstadd_back.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ana-lda- <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/23 20:14:21 by ana-lda- #+# #+# */
/* Updated: 2024/04/24 15:29:00 by ana-lda- ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lstadd_back(t_list **lst, t_list *new )
{
t_list *last;
if (*lst == NULL)
*lst = new;
else
{
last = *lst;
while (last->next != NULL)
last = last->next;
last->next = new;
}
}
/* #include <stdio.h>
int main(void)
{
t_list *n1;
t_list *new;
n1 = ft_lstnew("ola eu sou um noh");
new = ft_lstnew("i am the new node");
ft_lstadd_back(&n1, new);
printf("%s\n", (char *) n1->content);
printf("%s\n", (char *) n1->next->content);
} */