FGET— Read a single character in stream mode from stdin
This intrinsic is provided in both subroutine and function forms; however, only one form can be used in any given program unit.
Note that the
FGET intrinsic is provided for backwards compatibility with
g77. GNU Fortran provides the Fortran 2003 Stream facility.
Programmers should consider the use of new stream IO feature in new code
for future portability. See also Fortran 2003 status.
CALL FGET(C [, STATUS])
|C||The type shall be |
|STATUS||(Optional) status flag of type |
PROGRAM test_fget INTEGER, PARAMETER :: strlen = 100 INTEGER :: status, i = 1 CHARACTER(len=strlen) :: str = "" WRITE (*,*) 'Enter text:' DO CALL fget(str(i:i), status) if (status /= 0 .OR. i > strlen) exit i = i + 1 END DO WRITE (*,*) TRIM(str) END PROGRAM