1 / 18

計算機程式 C omputer Programming Language Lecture 7 檔案

計算機程式 C omputer Programming Language Lecture 7 檔案. 郭修伯 助理教授 (5488). 讀取檔案. 這個檔案的代碼為10. 更完整的情形 ( page 277):. 文字檔. Open(unit=10, file=‘a.txt’, form=‘formatted’, status=‘unknown’, & error=100, iostat=0, blank=null). 倒帶. Write/Read (unit=10, fmt=100, rec=2, iostat=error). 其他檔案操作指令.

anson
Download Presentation

計算機程式 C omputer Programming Language Lecture 7 檔案

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 計算機程式Computer Programming LanguageLecture 7 檔案 郭修伯 助理教授 (5488)

  2. 讀取檔案 這個檔案的代碼為10 更完整的情形 (page 277): 文字檔 Open(unit=10, file=‘a.txt’, form=‘formatted’, status=‘unknown’, & error=100, iostat=0, blank=null)

  3. 倒帶 Write/Read (unit=10, fmt=100, rec=2, iostat=error)

  4. 其他檔案操作指令 • Inquire (file=‘hello.txt’, exist=alive, iostat=0) • Backspace (unit=10, err=100, iostat=0) • Endfile (unit=10, err=100, iostat=0) • Rewind (unit=10, err=100 , iostat=0) • Close (unit=10, status=‘keep’, err=100 , iostat=0) • Close (unit=10, status=‘delete’, err=100 , iostat=0)

  5. 消去字串後多餘空白

  6. 開一個檔案,讀取其資料。若無檔案則警告。

  7. 記錄全班的國文、英文及數學成績

  8. 讀取國文、英文及數學成績並輸出

  9. 讀取不固定格式的資料 Cont...

  10. Cont..

  11. 將本來程式加上行號

  12. 存取方式 • 循序檔操作 (sequential) • 讀寫資料只能從頭開始一步步走。改變檔案讀寫位置時,只能一步步進退,或是跳到檔案開頭。 • 直接存取操作 (direct) • 事先將檔案空間分割成幾個同大小區塊,區塊會自動按順序編號。檔案讀寫時,先指定讀寫位置的區塊,再進行讀寫。

  13. 定義區塊大小:recl=6 6的原因:4個字元+2 在 microsoft 作業系統中,文字檔每一行行尾都有2個看不見的符號代表一行結束(Unix系統每個行尾為1個結束符號)

  14. 寫一個跳著輸入資料的程式

  15. 寫一程式讀取下面成績單,計算個人總分及各科平均分數寫一程式讀取下面成績單,計算個人總分及各科平均分數

  16. Cont.

  17. 使用內定輸入格式時,遇見空白字元會被當成分隔符號使用內定輸入格式時,遇見空白字元會被當成分隔符號

More Related