next up previous contents
Next: More File IO Up: Formatted File IO Previous: Formatted File IO

Solution

    PROGRAM Personnell_Stuph
     IMPLICIT NONE
     CHARACTER(LEN=15) :: name
     INTEGER :: age, tel_no, stat
     REAL :: height
      OPEN(UNIT=8, FILE='personnel.dat')
      WRITE(*,100)
  100 FORMAT(T22,'Height')
      WRITE(*,200)
  200 FORMAT(T4,'Name',T17,'Age',T21,'(metres)',T30,'Tel.  No.')
      WRITE(*,300)
  300 FORMAT(T4,'----',T17,'---',T21,' ------ ',T30,'--------')
      DO
       READ(8,*, IOSTAT= stat) name, age, height, tel_no 
       IF (stat<0) EXIT  ! Test for end of file
       WRITE(*,400) name, age, height, tel_no
  400  FORMAT(A,T17,I3,T23,F4.1,T32,I5)
      END DO
    END PROGRAM  Personnell_Stuph


next up previous contents
Next: More File IO Up: Formatted File IO Previous: Formatted File IO

©University of Liverpool, 1997
Thu May 29 10:11:26 BST 1997
Not for commercial use.