Archived
1

Added list pointer printing function

This commit is contained in:
2020-01-30 07:48:20 +01:00
parent b22a0977aa
commit 560ac1e59f
3 changed files with 27 additions and 8 deletions

View File

@ -1,6 +1,7 @@
#include "linked_list.h"
#include <stdlib.h>
#include <stdio.h>
static Node* create(void* data)
{
@ -20,6 +21,16 @@ void list_print(Node* head, void (*print_func)(void*))
}
}
void list_print_pointers(Node* head)
{
printf("%-19s%-19s%-19s%-19s\n", "Prev", "Current", "Next", "Data");
while (head)
{
printf("0x%p 0x%p 0x%p 0x%p\n", head->prev, head, head->next, head->data);
head = head->next;
}
}
void list_push(Node** head, void* data)
{
Node* node = create(data);

View File

@ -7,6 +7,8 @@ typedef struct Node {
void list_print(Node* head, void (*print_func)(void*));
void list_print_pointers(Node* head);
void list_push(Node** head, void* data);
void list_append(Node** head, void* data);