RosettaCodeData/Task/File-input-output/Fortran/file-input-output.f

22 lines
531 B
FortranFixed
Raw Permalink Normal View History

2013-04-10 21:29:02 -07:00
program FileIO
integer, parameter :: out = 123, in = 124
integer :: err
2016-12-05 22:15:40 +01:00
character :: c
2013-04-10 21:29:02 -07:00
open(out, file="output.txt", status="new", action="write", access="stream", iostat=err)
2016-12-05 22:15:40 +01:00
if (err == 0) then
2013-04-10 21:29:02 -07:00
open(in, file="input.txt", status="old", action="read", access="stream", iostat=err)
2016-12-05 22:15:40 +01:00
if (err == 0) then
2013-04-10 21:29:02 -07:00
err = 0
2016-12-05 22:15:40 +01:00
do while (err == 0)
2013-04-10 21:29:02 -07:00
read(unit=in, iostat=err) c
2016-12-05 22:15:40 +01:00
if (err == 0) write(out) c
2013-04-10 21:29:02 -07:00
end do
close(in)
end if
close(out)
end if
end program FileIO