-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_lstadd_back.c
60 lines (50 loc) · 1.58 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
58
59
60
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstadd_back.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sabraham <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/08/08 18:04:40 by sabraham #+# #+# */
/* Updated: 2023/08/08 18:07:48 by sabraham ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lstadd_back(t_list **lst, t_list *new)
{
t_list *ptr;
if (lst && new)
{
ptr = *lst;
if (ptr == NULL)
{
*lst = new;
return ;
}
while (ptr -> next)
{
ptr = ptr -> next;
}
ptr -> next = new;
}
}
// void print_list(t_list *head)
// {
// t_list *ptr;
// ptr = head;
// while (ptr != NULL)
// {
// printf("%s\n", ptr->content);
// ptr = ptr->next;
// }
// }
// int main()
// {
// t_list *head = ft_lstnew("sened");
// t_list *ptr1 = ft_lstnew("alex");
// ft_lstadd_back(&head, ptr1);
// //t_list *ptr2 = ft_lstnew("abraham");
// //ft_lstadd_back(&head, ptr2);
// print_list(head);
// return 0;
// }