From f5d92f4553d154c01538e064a9f63d3b5dc9b45a Mon Sep 17 00:00:00 2001 From: Collins331 Date: Fri, 15 Sep 2023 22:52:50 +0300 Subject: [PATCH] modified files --- 0x17-doubly_linked_lists/0-print_dlistint.c | 33 +++++++++++--------- 0x17-doubly_linked_lists/e | Bin 0 -> 16344 bytes 2 files changed, 18 insertions(+), 15 deletions(-) create mode 100755 0x17-doubly_linked_lists/e diff --git a/0x17-doubly_linked_lists/0-print_dlistint.c b/0x17-doubly_linked_lists/0-print_dlistint.c index 8be978e..b50f055 100644 --- a/0x17-doubly_linked_lists/0-print_dlistint.c +++ b/0x17-doubly_linked_lists/0-print_dlistint.c @@ -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); } diff --git a/0x17-doubly_linked_lists/e b/0x17-doubly_linked_lists/e new file mode 100755 index 0000000000000000000000000000000000000000..e1072318caf8917c741424a62db9018ebb413afb GIT binary patch literal 16344 zcmeHOZ*W{y6~CLbB|vGmrIpYMU6DHcG25g~I|U}PZL{r*lR|781xI+< ztt1@_kqDRx)#?Z2LqD`19Pke_)j_RaB(>Ut0}lP-lwov$p_)+CQ2euM?fN_Sp7ZkZ zy4ztGzc{`#^Y+~HJAdxI=f3y$-raj2Np@|ki$s)Az50|QX)0=v1S^_0aRDr$HmR%d zxmsPX7C~O1F{4iy2Cbpfb@O=xMBRza#8-g#Co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