Let us explore an example of file read. The subroutine readnums opens a file, reads the number in the file into an array, then returns. Listing 1 is the first trial.
Listing 1: | readnums.1 |
The first version readnums is quite simple, but it lacks many error detection and handling logic. Let us see how we can improve it.