Lecture 9-IO - File I/O 1 Files A file is an external collection of related data treated as a unit Since the contents of primary storage are lost

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
1 File I/O
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Files A file is an external collection of related data treated as a unit. Since the contents of primary storage are lost when the computer is shut down, we need files to store our data in a more permanent form . Additionally, the collection of data is often too large to reside in main memory at one time. We must have the ability to read and write portions of the data while the rest remain in the file.
Background image of page 2
3 Classes of Files There are two broad classes of files: Text Files : All the data are stored as characters which must be converted to internal formats when entered into memory. Text files are organized around lines which end with a new line(“|n”). Binary Files : Store data in internal computer formats , such as integer and floating-pt numbers. Take less time to I/O because no format conversion is necessary.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 Files are stored on auxiliary or secondary storage devices. Two most common are disk and tape. A buffer is a temporary storage area which holds data while they are being transferred to or from memory. Its primary purpose is to synchronize the physical devices to your program needs(e.g., more data can be input at one time then your program can use. The buffer holds extra data until you are ready for it).
Background image of page 4
5 These buffering activities are taken care of by software know as device drivers or access methods , which are provided by the supplier of the Operating System you are using.
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
6 Files and Streams The computer looks at input and output data, whether from a physical device such as a keyboard, or from secondary files, as a stream of characters or bytes . Since files exist separately from our program and computer, we must have some way to connect them: we must create a linkage between the external file and its usage in our program . In C, this linkage is know as a file table .
Background image of page 6
7 The term file table implies that several things are stored. It contains ALL the info needed to locate your file wherever it is stored outside of the computer. It also contains info such as the file name , the location of its file buffer , and the current state of the file. We define a file table with the standard FILE type . There will be a file table for each file that our program will access.
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
File System Basics The header <stdio.h> contains: Three file pointers(stdin, stdout, stderr). Several interrelated functions.
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/11/2011 for the course INDE 3333 taught by Professor Sontag during the Fall '11 term at University of Houston.

Page1 / 40

Lecture 9-IO - File I/O 1 Files A file is an external collection of related data treated as a unit Since the contents of primary storage are lost

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online