-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_lstadd_back.c
55 lines (49 loc) · 1.52 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstadd_back.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nmattera <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/18 19:11:00 by nmattera #+# #+# */
/* Updated: 2022/05/23 11:39:28 by nmattera ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lstadd_back(t_list **lst, t_list *new)
{
t_list *temp;
if (*lst && lst)
{
temp = *lst;
temp = ft_lstlast(temp);
temp->next = new;
}
else
*lst = new;
}
/* #include <stdio.h>
int main()
{
t_list *begin;
t_list *first;
t_list *second;
t_list *third;
int i;
begin = (t_list*)malloc(sizeof(t_list));
first = ft_lstnew("1");
second = ft_lstnew("2");
third = ft_lstnew("3");
ft_lstadd_back(&begin, first);
ft_lstadd_back(&begin, second);
ft_lstadd_back(&begin, third);
i = 0;
while(first->next)
{
printf("%s", (char *)first->content);
first = first->next;
i++;
}
printf("%s", (char *)first->content);
}
*/