forked from Oludammydy/monty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqueue.c
48 lines (46 loc) · 725 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
#include "monty.h"
/**
* f_queue - prints the top
* @head: stack head
* @counter: line_number
* Return: no return
*/
void f_queue(stack_t **head, unsigned int counter)
{
(void)head;
(void)counter;
bus.lifi = 1;
}
/**
* addqueue - add node to the tail stack
* @n: new_value
* @head: head of the stack
* Return: no return
*/
void addqueue(stack_t **head, int n)
{
stack_t *new_node, *aux;
aux = *head;
new_node = malloc(sizeof(stack_t));
if (new_node == NULL)
{
printf("Error\n");
}
new_node->n = n;
new_node->next = NULL;
if (aux)
{
while (aux->next)
aux = aux->next;
}
if (!aux)
{
*head = new_node;
new_node->prev = NULL;
}
else
{
aux->next = new_node;
new_node->prev = aux;
}
}