struct Stack* createStack(unsigned capacity){
struct Stack* stack = (struct Stack*) malloc(sizeof(struct Stack));
stack -> capacity = capacity;
stack -> array = (int*)malloc(stack -> capacity * (sizeof(int)));
bool isFull(struct Stack* stack){
return stack -> top == stack -> capacity - 1;
bool isEmpty(struct Stack* stack){
return stack -> top == - 1;
int pop(struct Stack* stack){
return stack->array[stack->top--];
void push(struct Stack* stack, int data){
stack->array[++stack->top] = data;
int peak(struct Stack* stack){
return stack->array[stack->top];
void printStack(struct Stack* stack){
for(int i = 0; i < stack->capacity; i++){
printf("stack[%d] = %d \n", i, stack->array[i]);