-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
34 lines (32 loc) · 636 Bytes
/
main.c
File metadata and controls
34 lines (32 loc) · 636 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
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "lists.h"
/**
* main - check the code
*
* Return: Always EXIT_SUCCESS.
*/
int main(void)
{
dlistint_t *head;
dlistint_t *new;
dlistint_t hello = {8, NULL, NULL};
size_t n;
head = &hello;
new = malloc(sizeof(dlistint_t));
if (new == NULL)
{
dprintf(2, "Error: Can't malloc\n");
return (EXIT_FAILURE);
}
new->n = 9;
head->prev = new;
new->next = head;
new->prev = NULL;
head = new;
n = print_dlistint(head);
printf("-> %lu elements\n", n);
free(new);
return (EXIT_SUCCESS);
}