-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdriver.c
50 lines (49 loc) · 1.02 KB
/
driver.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
#include <stdio.h>
#include <stdlib.h>
#include "stack.h"
int main (int argc, char *argv[]) {
char mode;
int print_num = 0;
int address;
printf("Welcome to the stack program. \n");
while (mode != 'x') {
printf("\n");
printf("Enter option: ");
scanf(" %c", &mode);
if (mode == 'u') {
printf("What number? ");
scanf("%d", &address);
if (push(address)==1) {
printf("Overflow!!!\n");
}
printStack(print_num);
}
else if (mode == 'o') {
int address;
if (pop(&address)==1) {
printf("Underflow!!!\n");
} else {
printf("Popped %d\n", address);}
printStack(print_num);
}
else if (mode == 'h') {
print_num = 1;
printStack(print_num);
}
else if (mode == 'c') {
print_num = 2;
printStack(print_num);
}
else if (mode == 'd') {
print_num = 0;
printStack(print_num);
}
else if (mode == 'x'){
printf("Goodbye! \n");
}
else {
printf("\n");
}
}
return 0;
}