-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_lstadd_front.c
More file actions
executable file
·56 lines (53 loc) · 1.81 KB
/
Copy pathft_lstadd_front.c
File metadata and controls
executable file
·56 lines (53 loc) · 1.81 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstadd_front.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ssoeno <ssoeno@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/21 10:34:38 by ssoeno #+# #+# */
/* Updated: 2024/04/23 23:23:34 by ssoeno ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lstadd_front(t_list **lst, t_list *new)
{
if (!lst || !new)
return ;
new->next = *lst;
*lst = new;
}
// void print_list(t_list *lst) {
// while (lst != NULL) {
// printf("%d -> ", *(int *)lst->content);
// lst = lst->next;
// }
// printf("NULL\n");
// }
// int main() {
// t_list *head = NULL;
// int *p1 = malloc(sizeof(int));
// int *p2 = malloc(sizeof(int));
// int *p3 = malloc(sizeof(int));
// if(p1 == NULL || p2 == NULL || p3 == NULL){
// return -1;
// }
// *p1 = 42;
// *p2 = 43;
// *p3 = 44;
// //make a new node and at it to the front
// t_list *new_node = ft_lstnew(p1);
// ft_lstadd_front(&head, new_node);
// new_node = ft_lstnew(p2);
// ft_lstadd_front(&head, new_node);
// new_node = ft_lstnew(p3);
// ft_lstadd_front(&head, new_node);
// print_list(head);
// t_list *tmp;
// while (head != NULL) {
// tmp = head;
// head = head->next;
// free(tmp);
// }
// return 0;
// }