-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
37 lines (30 loc) · 667 Bytes
/
Copy pathmain.c
File metadata and controls
37 lines (30 loc) · 667 Bytes
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
#include <stdio.h>
#include <stdlib.h>
#include "stack.h"
int main()
{
int i;
STACK hStack;
hStack = stack_init_default();
if(hStack == NULL)
{
printf("Failed to allocate memory for hStack object\n");
exit(1);
}
stack_push(hStack, 4);
stack_push(hStack, 6);
stack_push(hStack, 8);
stack_push(hStack, 10);
stack_pop(hStack);
while(!stack_empty(hStack))
{
printf("%d\n", stack_top(hStack, NULL));
stack_pop(hStack);
if(stack_empty(hStack))
{
printf("Stack is empty\n");
}
}
stack_destroy(&hStack);
return 0;
}