C omputer programming language lecture 7
This presentation is the property of its rightful owner.
Sponsored Links
1 / 18

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


  • 59 Views
  • Uploaded on
  • Presentation posted in: General

計算機程式 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). 其他檔案操作指令.

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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


C omputer programming language lecture 7

計算機程式Computer Programming LanguageLecture 7 檔案

郭修伯 助理教授 (5488)


C omputer programming language lecture 7

讀取檔案

這個檔案的代碼為10

更完整的情形 (page 277):

文字檔

Open(unit=10, file=‘a.txt’, form=‘formatted’, status=‘unknown’, & error=100, iostat=0, blank=null)


C omputer programming language lecture 7

倒帶

Write/Read (unit=10, fmt=100, rec=2, iostat=error)


C omputer programming language lecture 7

其他檔案操作指令

  • 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)


C omputer programming language lecture 7

消去字串後多餘空白


C omputer programming language lecture 7

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


C omputer programming language lecture 7

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


C omputer programming language lecture 7

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


C omputer programming language lecture 7

讀取不固定格式的資料

Cont...


C omputer programming language lecture 7

Cont..


C omputer programming language lecture 7

將本來程式加上行號


C omputer programming language lecture 7

存取方式

  • 循序檔操作 (sequential)

    • 讀寫資料只能從頭開始一步步走。改變檔案讀寫位置時,只能一步步進退,或是跳到檔案開頭。

  • 直接存取操作 (direct)

    • 事先將檔案空間分割成幾個同大小區塊,區塊會自動按順序編號。檔案讀寫時,先指定讀寫位置的區塊,再進行讀寫。


C omputer programming language lecture 7

定義區塊大小:recl=6

6的原因:4個字元+2

在 microsoft 作業系統中,文字檔每一行行尾都有2個看不見的符號代表一行結束(Unix系統每個行尾為1個結束符號)


C omputer programming language lecture 7

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


C omputer programming language lecture 7

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


C omputer programming language lecture 7

Cont.


C omputer programming language lecture 7

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


  • Login