-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path0-main.c
More file actions
40 lines (36 loc) · 681 Bytes
/
0-main.c
File metadata and controls
40 lines (36 loc) · 681 Bytes
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
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "lists.h"
/**
* main - check the code
*
* Return: Always 0.
*/
int main(void)
{
list_t *head;
list_t *new;
list_t hello = {"World", 5, NULL};
size_t n;
head = &hello;
new = malloc(sizeof(list_t));
if (new == NULL)
{
printf("Error\n");
return (1);
}
new->str = strdup("Hello");
new->len = 5;
new->next = head;
head = new;
n = print_list(head);
printf("-> %lu elements\n", n);
printf("\n");
free(new->str);
new->str = NULL;
n = print_list(head);
printf("-> %lu elements\n", n);
free(new);
return (0);
}