-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack.c
More file actions
37 lines (37 loc) · 698 Bytes
/
Copy pathstack.c
File metadata and controls
37 lines (37 loc) · 698 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>
struct stack {
int size;
int top;
int *arr;
};
int isEmpty(struct stack *s){
if((*s).top==-1){
return 1;
}
return 0;
}
int isFull(struct stack *s){
if((*s).top==(*s).size-1){
return 1;
}
return 0;
}
int main(){
struct stack *s = (struct stack *)malloc(sizeof(struct stack));
(*s).size=80;
(*s).top=-1;
(*s).arr=(int *)malloc(((*s).size)*sizeof(int));
if(isEmpty(s)){
printf("The stack is empty");
}
else{
printf("The stack is not empty");
}
if(isFull(s)){
printf("The stack is full");
}
else{
printf("The stack is not full");
}
}