Lecture 21 Objectives
At the end of today's class you should
KNOW:
- That files provide a way to store data permanently (beyond the execution
of a program)
- Opening/closing a file associates/disassociates a file pointer with the operating system's
information about the file
- That files may be opened in read, write, or append mode
- Once a file has been opened, subsequent read/write operations are processed
using the file pointer
- The difference between text files and binary files
BE ABLE TO:
- Open, close, and read/write to a text file
Sample Exam Question:
Write a segment of C code that will:
- open a file for writing. The file will be stored in the current directory
under the name "student.dat"
- if the file could not be opened, print an error message
- otherwise, write these three lines to the file:
John A. Student
WPI
2011
- close the file