// stack.h // Abstract Data Type const int MAX=8; typedef struct { char elt[MAX]; int top; } STACK; // push data onto a stack int push(char item, STACK *s_ptr) { if (is_full(*s_ptr)) return (-1); // stack is full so cannot push else { // (*s_ptr).top--; // (* dereference the pointer) then select. element s_ptr->top--; // dereference and then select -> s_ptr->elt[ s_ptr->top ] = item; return (0); } } // pop data off of a stack int pop( STACK *s_ptr) { if (is_empty(*s_ptr)) return (-1); else { return s_ptr->elt[s_ptr->top++]; } } // is stack empty? int is_empty(STACK s) { if (s.top >= MAX) return (1); else return (0); } // is stack full? int is_full( STACK s) { if (s.top <= 0) return (1); else return (0); }