177. Read a file into a string with unformatted stream.#

topic: Input and Output

Note

This tip is a draft1.

An entire file can be read into a string by

(1) using INQUIRE to get the file size (2) allocating a string to this size (3) reading the string using unformatted stream

The string can then be broken into lines by searching for newline characters.



1

From the perspective of FortranTip Browser, “draft” means that it hasn’t been edited for formatting, hasn’t had corresponding Fortran programs added, the text content hasn’t been enhanced, etc. Draft texts are extracted from the corresponding Tweet using the Twitter API.