-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_lstnew_bonus.c
51 lines (43 loc) · 1.69 KB
/
ft_lstnew_bonus.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstnew_bonus.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ledias-d <[email protected]> #+# +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024-10-11 12:55:56 by ledias-d #+# #+# */
/* Updated: 2024-10-11 12:55:56 by ledias-d ### ########.rio */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lstnew(void *content)
{
t_list *elem;
elem = malloc(sizeof(t_list));
if (!elem)
return (NULL);
elem->content = content;
elem->next = NULL;
return (elem);
}
/*#include <stdio.h>
int main(void)
{
char *content = "Hello, 42!";
t_list *new_node = ft_lstnew((void *)content);
if (new_node == NULL)
printf("Erro: malloc falhou\n");
else
{
if (new_node->content == content)
printf("Teste 1 passou: Conteúdo está correto.\n");
else
printf("Teste 1 falhou: Conteúdo está incorreto.\n");
if (new_node->next == NULL)
printf("Teste 2 passou: O ponteiro 'next' está NULL.\n");
else
printf("Teste 2 falhou: O ponteiro 'next' não está NULL.\n");
free(new_node);
}
return (0);
}*/