Home Segments Index Top Previous Next

86: Sidetrip

Later on, in the hardcopy version of this book, you learn about mechanisms that enable you to read data from files. Meanwhile, if you happen to be using Unix or Dos, you may want to take advantage of the input-redirection mechanism that enables you to tell your program to accept input from a file as though that input were coming from your keyboard.

To supply information from a file, you first prepare a file containing the characters that you would have supplied from your keyboard:

600 100 200 

The command line that redirects input from your keyboard to the file is as follows, assuming that your program's name is average_size, and that your data file's name is test_data,

average_size < test_data