10/07/03 01:44:30
>>219
program hyoujisurudake2
implicit none
integer :: i, io, ip1, ip2, ip3
CHARACTER(LEN = 80) :: text
integer :: iprice, iyear, imonth, iday
open(10,file='data614.txt',status='old')
i = 0
do
read(10, '(a)', iostat = io) text
if(io <= -1 ) exit
i=i+1
ip1 = INDEX(text, '/')
ip2 = INDEX(text, '/', BACK = .TRUE.)
ip3 = INDEX(text, ',')
READ(text( 1:ip1 - 1), *) iyear
READ(text(ip1 + 1:ip2 - 1), *) imonth
READ(text(ip2 + 1:ip3 - 1), *) iday
READ(text(ip3 + 1: ), *) iprice
print * , i, iprice, iyear, imonth, iday
end do
close(10)
stop
end
1 12345 1999 12 31
2 23456 2000 1 1
3 23456 2000 1 2
続行するには何かキーを押してください . . .
この入力データで問題となるのは、FORTRANの書式指定無しの場合、スラッシュ『/』は改行を意味する制御文字に
なっている点だ。これを知らないと、何故か入力がなされなくて、地獄へ落ちる!