ft_lstnew: initial implementation
This commit is contained in:
parent
1126640edc
commit
8777bfc3c3
3 changed files with 50 additions and 2 deletions
41
ft_lstnew_bonus.c
Normal file
41
ft_lstnew_bonus.c
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_lstnew_bonus.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: kcolin <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/21 11:19:42 by kcolin #+# #+# */
|
||||
/* Updated: 2024/10/21 11:25:46 by kcolin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
t_list *ft_lstnew(void *content)
|
||||
{
|
||||
t_list *out;
|
||||
|
||||
out = malloc(sizeof(t_list));
|
||||
if (out == NULL)
|
||||
return (NULL);
|
||||
out->content = content;
|
||||
out->next = NULL;
|
||||
return (out);
|
||||
}
|
||||
|
||||
/*
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
t_list *list;
|
||||
|
||||
list = ft_lstnew("Hello There!");
|
||||
printf("content:\t%s\n", (char *)list->content);
|
||||
printf("next:\t%p\n", list->next);
|
||||
free(list);
|
||||
return (0);
|
||||
}
|
||||
*/
|
||||
Loading…
Add table
Add a link
Reference in a new issue