C omputer programming language lecture 7
Download
1 / 18

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


  • 73 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). 其他檔案操作指令.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha

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
存取方式

  • 循序檔操作 (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

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


C omputer programming language lecture 7

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


ad
  • Login