-
Notifications
You must be signed in to change notification settings - Fork 2
/
functions1.c
63 lines (54 loc) · 1 KB
/
functions1.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
52
53
54
55
56
57
58
59
60
61
62
63
#include "monty.h"
/**
* f_pop - print top node on stack
* @head: pointer to pointer of first node
* @counter: line counter
*
* Return: none
*/
void f_pop(stack_t **head, unsigned int counter)
{
stack_t *h;
if (*head == NULL)
{
fprintf(stderr, "L%d: can't pop an empty stack\n", counter);
fclose(bus.file);
free(bus.content);
free_stack(*head);
exit(EXIT_FAILURE);
}
h = *head;
*head = h->next;
free(h);
}
/**
* f_pint - print top node on stack
* @head: pointer to pointer of first node
* @counter: line counter
*
* Return: none
*/
void f_pint(stack_t **head, unsigned int counter)
{
if (*head == NULL)
{
fprintf(stderr, "L%u: can't pint, stack empty\n", counter);
fclose(bus.file);
free(bus.content);
free_stack(*head);
exit(EXIT_FAILURE);
}
printf("%d\n", (*head)->n);
}
/**
* f_nop - do nothing
* @head: pointer to pointer of first node
* @counter: line counter
*
* Return: none
*/
void f_nop(stack_t **head, unsigned int counter)
{
(void) counter;
(void) head;
}