Strings and Internal I/O
Internal I/O
Write Into a Buffer
Internal I/O writes formatted output into a character variable instead of a file or screen.
Program
Play the program to format a number into a string buffer.
internal_io.f90
program internal_io
implicit none
character(len=32) :: buf
integer :: count
count = 42
write(buf, '(A, I0)') "count=", count
print '(A)', trim(buf)
end program internal_io
internal write
`write(buf, fmt) ...` writes into a character variable.
format
`'(A, I0)'` joins a string and a minimum-width integer.
trim
`trim(buf)` strips trailing blanks before printing.