看板 Fortran 關於我們 聯絡資訊
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
HULK10425:我這個程式是想要把資料寫到一個陣列裡面! 02/04 12:02
HULK10425:可是一直寫不進去。 02/04 12:02
Cypresslin:你的檔案沒有必要打開兩次,要的話也要先關掉第一次的 02/04 12:09
Cypresslin:可以用rewind(a)來將讀取位置歸位 02/04 12:10
Cypresslin:另外恕我直言,您的排版改一下會讓閱讀更方便 02/04 12:11
HULK10425:好的,我會改一下排版的。 02/04 12:24
HULK10425:!!!您太神了,加了close以後就可以執行了。 02/04 12:26
HULK10425:非常感謝 ^^ 02/04 12:26