Introduction to Files and Streams
You might have heard of I/O. It stands for Input-Output. In this section we'll take a look at the C++ file system.
Using C++ you can access a device through an intermediate medium. The intermediate medium is called as stream. The device that you access is known as file.
Don't mistake the term file as a normal computer file. A normal file ( a text file or a word document ) is referred to as disk file. In this case file takes a broader meaning. It includes disk files, tape drives, the terminal, printers and so on. C++ is designed to work with these devices. To work with them you have streams. You can access devices using streams.
The point is : Each device is different. Each one is unique. The C++ file system transforms each device into a stream. All streams will behave similarly though they provide access to different devices (or files). Hence streams are mostly device-independent. The function used to write to a disk file can be used to write to a printer as well. Hence all streams are similar but files are not.
Each stream is associated with a specific file by using the open operation. Once you open a file (not just disk file - could be a printer) information can be exchanged between the file and your c++ program. This exchange is done through streams.
In the next section we'll see about Opening and Closing a File
or go back to Contents page 2.