Added list pointer printing function
This commit is contained in:
@ -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);
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user