/* The stack pointer always points to the first free position on the stack. This is the common way to implement the stack. */ #include "stack.h" ElementType stack [30]; int stackPointer = 0; void push(ElementType element) { stack[stackPointer] = element; stackPointer++; } bool isEmpty() { return stackPointer == 0; } ElementType pop() { if (!isEmpty()) { stackPointer--; return stack[stackPointer]; } }