Next: Bad File
Up: File Errors
Previous: End of File

Bad Input

The program that we just looked at expects to find a two-digit integer at the beginning of every line in the input file. What happens if this isn't the case? Let's try it and find out. Edit the file that the program in ``file5.f'' reads by adding some lines that have alphabetic characters in the first two columns. Then rerun the program. What happens?

Click here for the answer

It would be nice if we could do something besides crash when we find an error in the input. What are some things that we might want to do?

Click here for the answer

For example, we might decide that if we encounter bad input, we'll just print out a warning and skip over that line and continue with the next one. Take a look at ``file6.f'' (or view it directly) for an example of how to do that. How does ``file6.f'' differ from ``file5.f''?

Click here for the answer

Change 'filename' to the actual filename that you used in ``file5.f'', and run the program to see what happens.


Next: Bad File
Up: File Errors
Previous: End of File

Hamlet Project
hamlet@cs.utah.edu