home *** CD-ROM | disk | FTP | other *** search
- /* .subt | stack routines for the desktop calculator */
-
- #define MAXVAL 100
-
- int sp = 0;
- double val[MAXVAL];
-
- double push(f)
- double f;
- {
- if (sp < MAXVAL)
- return(val[sp++] = f);
- else {
- printf("error: stack full\n");
- clear();
- return(0.0);
- }
- }
-
- double pop()
- {
- if (sp > 0)
- return(val[--sp]);
- else {
- printf("error: stack empty\n");
- clear();
- return(0.0);
- }
- }
-
- clear()
- {
- sp = 0;
- }
-
- /* .subt < end of file, stack.c */
-
-