Skip to content

Commit

Permalink
modified files
Browse files Browse the repository at this point in the history
  • Loading branch information
Collins331 committed Sep 15, 2023
1 parent c904dfa commit f5d92f4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions 0x17-doubly_linked_lists/0-print_dlistint.c
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
#include "lists.h"

/**
* print_dlistint - prints all elements of linked list
* @h: pointer to the list
* Return: the number of nodes
* print_dlistint - prints all the elements of a dlistint_t list.
* @h: pointer to the head of the list
*
* Return: number of nodes
*/

size_t print_dlistint(const dlistint_t *h)
{
dlistint_t *newnode;
size_t count = 0;

int counter = 0;

if (h == NULL)
return (count);
newnode = malloc(sizeof(dlistint_t));
newnode->n = h->n;
newnode->prev = h->prev;
newnode->next = h->next;
return (counter);

while (newnode != NULL)
while (h->prev != NULL)
h = h->prev;

while (h != NULL)
{
printf("%d\n", newnode->n);
count++;
newnode = newnode->next;
printf("%d\n", h->n);
h = h->next;
counter++;
}
return (count);

return (counter);
}
Binary file added 0x17-doubly_linked_lists/e
Binary file not shown.

0 comments on commit f5d92f4

Please sign in to comment.