#include <stdio.h>
#include <stdlib.h>
#define MAX 10
typedef struct
{
char data[MAX];
int top;
}STACK;
STACK s;
char ch;
void initstack()
{
s.top = -1;
}
int isfull()
{
if(s.top == MAX-1)
return 1;
else
return 0;
}
int isempty()
{
if(s.top == -1)
return 1;
else
return 0;
}
void push(char ch)
{
if(isfull())
printf(">>STACK IS FULL<<");
else
{
printf("\tchar=%c",ch);
s.top++;
s.data[s.top]=ch;
printf("\ttop=%d",s.top);
}
}
char pop()
{
if(isempty())
printf(">>STACK IS EMPTY<<");
else
{
printf("\n\n pop top=%d",s.top);
ch=s.data[s.top];
s.top = s.top -1;
return ch;
}
}