#include #include #include "calc.h" #include "stack.h" #define SIZE 100 static number stack[SIZE]; static int top=0; int push(double d) { if( top < SIZE - 1){ stack[top] = d; top++; return 1; } return 0; } void printStack() { if( isStackEmpty() ) return; for(int i=0; i < top; i++){ printf(NUMFMT " ", stack[i]); } putchar('\n'); } void emptyStack() { top = 0; } int isStackEmpty() { return top <= 0; } double pop() { if(isStackEmpty()){ fprintf(stderr,"oops empty stack programming error"); exit(1); } top --; return stack[top]; }