-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_stack.c
More file actions
47 lines (38 loc) · 821 Bytes
/
Copy pathmain_stack.c
File metadata and controls
47 lines (38 loc) · 821 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
38
39
40
41
42
43
44
45
#include <stdio.h>
#include <stdlib.h>
#include "stack.h"
int main()
{
Block *head = NULL; /* initialize stack */
while(1)
{
printf("\n\n\n==== Stack ====\n");
printf("1) push\t2) pop\t3) print stack\t4) exit\nEnter option: ");
char msg[MSG_SIZE];
/* get option from stdin */
int option = 0;
char enterFilter;
scanf("%d%c", &option, &enterFilter);
switch(option)
{
case 1:
/* push, get line from user */
printf("Enter some messange: ");
scanf("%s", msg);
push(msg, &head);
break;
case 2:
pop(&head);
break;
case 3:
print_stack(&head);
break;
case 4:
exit(0);
break;
default:
printf("ERROR: wrong option, please enter again.\n");
}
}
return 0;
}