-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqueue.c
51 lines (48 loc) · 773 Bytes
/
queue.c
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "monty.h"
/**
* f_queue - function that prints the top of the queue
* @head: head of queue
* @counter: line count
*
* Return: nothing
*/
void f_queue(stack_t **head, unsigned int counter)
{
(void)head;
(void)counter;
bus.lifi = 1;
}
/**
* addqueue - function that add node to the tail the queue
* @n: new value
* @head: head of the queue
*
* Return: nothing
*/
void addqueue(stack_t **head, int n)
{
stack_t *new_node, *temp;
temp = *head;
new_node = malloc(sizeof(stack_t));
if (new_node == NULL)
{
printf("Error\n");
}
new_node->n = n;
new_node->next = NULL;
if (temp)
{
while (temp->next)
temp = temp->next;
}
if (!temp)
{
*head = new_node;
new_node->prev = NULL;
}
else
{
temp->next = new_node;
new_node->prev = temp;
}
}