#include <stdio.h>
#include <stdlib.h>
#define MaxSize 10
#define ElemType char
typedef struct
{
ElemType data[MaxSize];
int top;
}SqStack;
void InitStack(SqStack *&s)
{
s=(SqStack *)malloc(sizeof(SqStack));
s->top=-1;
}
int Push(SqStack *&s,ElemType e)
{
if (s->top==MaxSize-1)
return 0;
s->top++;
s->data[s->top]=e;
return 1;
}
void DispStack(SqStack *s)
{
int i;
for (i=s->top;i>=0;i--)
printf("%c ",s->data[i]);
printf("\n");
}
int StackEmpty(SqStack *s)
{
return(s->top==-1);
}
void ClearStack(SqStack *&s)
{
free(s);
}
int main()
{
SqStack *L;
int empty;
InitStack(L);
empty = StackEmpty(L);
printf("%d\n",empty);
Push(L,'a');
Push(L,'b');
Push(L,'c');
Push(L,'d');
empty = StackEmpty(L);
printf("%d\n",empty);
DispStack(L);
empty = StackEmpty(L);
printf("%d\n",empty);
ClearStack(L);
return 0;
}