-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack.c
More file actions
44 lines (37 loc) · 679 Bytes
/
Copy pathstack.c
File metadata and controls
44 lines (37 loc) · 679 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
#include "stack.h"
#include <stdio.h>
#include <stdlib.h>
struct aStack{
int value;
int stack[SIZE];
int pointer;
int aBP;
};
struct aStack *makeStack(){
struct aStack *a = malloc(sizeof(struct aStack));
a->value = 0;
a->pointer = 0;
a->aBP = 0;
return a;
}
void ptr_decrease(struct aStack *a){
a->pointer -=1;
}
int get_value(struct aStack *a){
return a->stack[a->pointer];
}
void add_value(struct aStack *a){
a->pointer+=1;
if(a->pointer >= SIZE){
fprintf(stderr,"stack full\n");
exit(1);
}
a->stack[a->pointer] = a->value;
a->value +=1;
}
void BP(struct aStack *a){
a->aBP = 1;
}
int isBP(struct aStack *a){
return a->aBP;
}