[問題] 出現看不懂的error

看板Fortran作者 (菩提王子)時間12年前 (2012/02/04 12:01), 編輯推噓0(008)
留言8則, 2人參與, 最新討論串1/1
program main implicit none integer, parameter::a=10,b=20 integer c integer count character, allocatable::o(:) character*200 d integer e integer error integer i open(a,file="call_price.txt",status="old") count = 0 do while(.true.) read(a,"(A200)",iostat=c)d if(c/=0) exit count=count+1 e=count end do write(*,*)count allocate(o(e)) open(a,file="call_price.txt") do i=1, e read(*,*)o(i) end do stop end 執行以後會出現 Error 84,only blank may be changed for a file that exists for a given program 想請教各位大師們,這是出現了甚麼問題呢? 感謝。ORZ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.116.1.134

02/04 12:02, , 1F
我這個程式是想要把資料寫到一個陣列裡面!
02/04 12:02, 1F

02/04 12:02, , 2F
可是一直寫不進去。
02/04 12:02, 2F

02/04 12:09, , 3F
你的檔案沒有必要打開兩次,要的話也要先關掉第一次的
02/04 12:09, 3F

02/04 12:10, , 4F
可以用rewind(a)來將讀取位置歸位
02/04 12:10, 4F

02/04 12:11, , 5F
另外恕我直言,您的排版改一下會讓閱讀更方便
02/04 12:11, 5F

02/04 12:24, , 6F
好的,我會改一下排版的。
02/04 12:24, 6F

02/04 12:26, , 7F
!!!您太神了,加了close以後就可以執行了。
02/04 12:26, 7F

02/04 12:26, , 8F
非常感謝 ^^
02/04 12:26, 8F
文章代碼(AID): #1FBAr_8P (Fortran)