Why Use File for I/O?
There are advantages for using files for I/O.
-
Reading data from input file is better than typing data in from the keyboard:
-
Instead of having to wait at the computer during program execution to enter the data, the data can be prepared in advance and checked for accuracy before running the program.
-
A large amount of data can be handled unattended using files.
-
Writing output data out to a file is better than sending the data to the screen:
-
The screen can only display a limited amount of information.
One has to sit by the screen to see the information.
The information is easily lost after it is displayed.
-
On the other hand, information can be written to a file unattended. A large amount of data can be handled. The information is stored permanently in the file until erased by the user.