-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.c
42 lines (32 loc) · 1.06 KB
/
main.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
// MT, 2016feb28
//#define NDEBUG
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include "Obj.h"
#include "Stack.h"
int main()
{
struct Stack * s = Stack_create(true);
Stack_push(s, Obj_bool_create(true));
Stack_push(s, Obj_char_create('A'));
Stack_push(s, Obj_int_create(42));
Stack_push(s, Obj_double_create(1234.5678));
printf("POP %f\n", *(double*)Stack_pop(s));
printf("POP %d\n", *(int*)Stack_pop(s));
printf("TOP %c\n", *(char*)Stack_top(s));
printf("TOP %c\n", *(char*)Stack_top(s));
Stack_clear(s);
printf("EMPTY? %d\n", (int)Stack_isEmpty(s));
Stack_push(s, Obj_bool_create(false));
printf("EMPTY? %d\n", (int)Stack_isEmpty(s));
Stack_push(s, Obj_char_create('B'));
printf("POP %c\n", *(char*)Stack_pop(s));
Stack_push(s, Obj_int_create(666));
printf("POP %d\n", *(int*)Stack_pop(s));
Stack_push(s, Obj_double_create(321.654));
printf("TOP %f\n", *(double*)Stack_top(s));
Stack_delete(s);
s = NULL;
return EXIT_SUCCESS;
}