{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lecture 9 -IO - File I/O 1 Files A file is an external...

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

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

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

View Full Document Right 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.
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.
Image of page 3

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

View Full Document Right 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).
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.
Image of page 5

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

View Full Document Right 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 .
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.
Image of page 7

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern