Libft
42 Libft library documentation
Loading...
Searching...
No Matches
ft_lstadd_front.c File Reference
+ Include dependency graph for ft_lstadd_front.c:

Go to the source code of this file.

Functions

void ft_lstadd_front (t_list **lst, t_list *new)
 Adds a new element to the front of a linked list. This function takes a pointer to the first element of a linked list and a new element, then adds the new element to the front of the list. The new element becomes the new head of the list.
 

Function Documentation

◆ ft_lstadd_front()

void ft_lstadd_front ( t_list **  lst,
t_list new 
)

Adds a new element to the front of a linked list. This function takes a pointer to the first element of a linked list and a new element, then adds the new element to the front of the list. The new element becomes the new head of the list.

Parameters
lstA pointer to the pointer to the first element of the list.
newThe new element to add to the front of the list.

Definition at line 24 of file ft_lstadd_front.c.

25{
26 if (!lst || !new)
27 return ;
28 new->next = *lst;
29 *lst = new;
30}