#include #include "calc.h" #define MAXVAL 100 /* maximum depth of val stack */ int sp = 0; /* next free stack position */ double val[MAXVAL]; /* value stack */ /* push: push f onto value stack */ void push(double f) { if (sp < MAXVAL) val[sp++] = f; else fprintf(stderr,"error: pila llena %g\n", f); } /* pop: pop and return top value from stack */ double pop(void) { if (sp > 0) return val[--sp]; else { fprintf(stderr,"error: pila vacia\n"); return 0.0; } } void ClearStack(void) { sp=0; puts("Pila vaciada"); } void PrintStack(void) { int i=sp; while(i) printf(FORMATO_F,val[--i]); }