The following files implement the Postfix (Reverse Polish Notation)
calculator, presented in chapter 4 of the K & R-II textbook. To
test this program, download each of the files, and then issue the
command make
.
-
getch.h: declarations related to the file
getch.c.
-
getch.c: functions that implement a buffer
for the standard input stream, allowing us to put-back characters
for later retrieval.
-
stack.h: declarations related to the file
stack.c.
-
stack.c: functions that implement a stack of
double-precision numbers (Last-In, First-Out ordering rule).
-
getop.h: declarations related to the file
getop.c.
-
getop.c: function that collects and identifies user
input (number, numeric operators)
-
stack.c: function that scans the standard input,
using the buffered-input functions of getch.c, so as
to extract ether the characters that make up a double-precision number or
an operator symbol (+, -, *, /). The newline control character is also
a possible return value.
-
str2double.h: declarations related to the file
str2double.c.
-
str2double.c: function that scans the characters
given in its parameter to compute the corresponding double-precision value.
-
rpn-calc.c: main() function for the program,
combining all of the above functionality.
-
Makefile: input for the
make
utility
program, containg the rules for building the executable. Defines
dependencies between the various files. For details, check the
man pages (command: man make).
Please note that a Makefile must use tab characters for indentation.
Close this window