Lecture Notes on File Handling and Streams
Introduction
- Study of file handling and streams
- Using standard input and output
Standard Input and Output
- Input: Data received from the keyboard
- Output: Data displayed on the monitor
- Data is temporary, if the program exits, the data is not saved.
Purpose of File Handling
- To store data permanently on the hard disk as a file.
fstream header file is used for file handling.
Streams
- Meaning of streams: Interface between input/output devices and programs.
- Data is processed in the form of a sequence of bytes.
C++ Stream Classes
istream and ostream classes:
cin: To receive input
cout: To display output
Use of Streams in File Handling
ifstream is used to read data from a file.
ofstream is used to write data to a file.
fstream: For both reading and writing to a file.
Interface of Stream and File
- Input and output streams are used for files.
- Utilizing streams is essential to permanently save data to a file.
Purpose of the Program
- To take data directly from the keyboard and write it to a file.
- To store data permanently in a file from the program.
Main Classes
ifstream (for input streams)
ofstream (for output streams)
fstream (for both input and output)
Conclusion
- Further activities will include more information and experiments on file handling.
- For more information, visit EasyTutsForYou.com.
Note: These notes cover the main points of the lecture related to file handling and streams.