USING FILE REDIRECTION
It can be tedious to repeatedly type these transactions as input to the programs you are testing. Most operating systems support file redirection, which lets us associate a named file with the standard input and the standard output:
- $ addItems <infile >outfile
Assuming $ is the system prompt and our addition program has been compiled into an executable file named addItems.exe (or addItems on UNIX systems), this command will read transactions from a file named infile and write its output to a file named outfile in the current directory.
EXERCISES SECTION 1.5.1
Exercise 1.20: http://www.informit.com/title/032174113 contains a copy of Sales_item.h in the Chapter 1 code directory. Copy that file to your working directory. Use it to write a program that reads a set of book sales transactions, writing each transaction to the standard output.
Exercise 1.21: Write a program that reads two Sales_item objects that have the same ISBN and produces their sum.
Exercise 1.22: Write a program that reads several transactions for the same ISBN. Write the sum of all the transactions that were read. 0321714113