Next: Checkoff
Up: Formatting
Previous: Format Tyranny

Skipping over characters

Suppose that you wanted to be able to read date from the keyboard, written in the form

12.02.92

where a two-digit month code is followed by a period, a two-digit day, another period, and a two-digit year code. Why would this be impossible to do without formatted input?

Click here for the answer

Look at ``date1.f'' (or view it directly) for an example of a program that reads dates in that format and then prints back the different parts.

This program illustrates two useful features of FORMAT statements.

First, notice the use of ``TR1'' in the first FORMAT statement. What does this do?

Click here for the answer

Second, look at the final three FORMAT statements to see how character strings can be incorporated into FORMAT statements.

Try rerunning ``date1.f'', but deliberately enter the date in the wrong format. (Enter 2.3.4, for example.) What happens?

Click here for the answer


Next: Checkoff
Up: Formatting
Previous: Format Tyranny

Hamlet Project
hamlet@cs.utah.edu