So far the programs are written following the console I/O operations. The inputs are taken through keyboard, these inputs and calculated data are stored in the memory, i.e., in the RAM and output is shown through VDU. But there are some problems related to this system when we need to handle large volume of data. As the data are stored in the main memory, the entire data set is lost as soon as the program is terminated. So for next execution of the program we need to enter the entire inputs. It is very tedious and time consuming to take input a large volume of data through keyboard every time the program executes. Thus it would be much better if we able to store these data permanently so that we can read back whenever required. The solution is file as file is the only place where the data can be stored permanently. C supports a large set of library functions for file handling. These are known as disk I/O or file I/O functions. In this chapter, we will discuss about files I/O functions which help us to know how to write data in files and how to read data from files. These are almost similar to console I/O functions except that these are operated on files.
WHAT IS A FILE?
A file can be defined as a repository of data or more preciously collection of bytes stored on a secondary storage device as it is permanent storage of data. Depending on the interpretation of these bytes several types of file may form. It may form textual document, a database file, an image file or file of any other form. The type of a particular file is decided entirely by the data structures and operations used by a program to process the file.
Depending on the way a file is opened for processing, a file can be classified as a text file or a binary file. The mode of opening a particular file differs in three main areas.
Review the options below to login to check your access.
Log in with your Cambridge Aspire website account to check access.
If you believe you should have access to this content, please contact your institutional librarian or consult our FAQ page for further information about accessing our content.