#include <iostream>
using namespace std;
typedef struct stackArr
{
int *arr;
int cap;
int top;
}STACK;
STACK* create_stack(int total)
{
STACK* stack = new(STACK);
stack->arr =new int[total];
stack->cap = total;
stack->top = 0;
return stack;
}
void stack_destroy(STACK* stack)
{
delete(stack->arr);
delete(stack);
}
void stack_push(STACK* stack , int data)
{
stack->arr[stack->top++] = data;
}
int stack_pop(STACK* stack)
{
return stack->arr[--stack->top];
}
void stack_clear(STACK* stack)
{
stack->top = 0;
}
int stack_size(STACK* stack)
{
return stack->top;
}
bool stack_empty(STACK* stack)
{
if(0 !=stack->top)
{
return false;
}
else
{
return true;
}
}
bool stack_full(STACK* stack)
{
if(stack->cap==stack->top)
{
return true;
}
else
{
return false;
}
}
int main()
{
STACK* stack =create_stack(10);
int i=0;
while( !stack_full(stack))
{
stack_push(stack, i++);
}
while( !stack_empty(stack))
{
cout<<stack_pop(stack)<<endl;
}
stack_destroy(stack);
return 0;
}