Skip to main content Accessibility help
×
Hostname: page-component-6bb9c88b65-zjgpb Total loading time: 0 Render date: 2025-07-27T09:52:35.660Z Has data issue: false hasContentIssue false

16 - File

Published online by Cambridge University Press:  17 July 2025

Subrata Saha
Affiliation:
Techno India Hooghly, West Bengal
Subhodip Mukherjee
Affiliation:
Techno India College of Technology, West Bengal
Get access

Summary

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.

Information

Type
Chapter
Information
Publisher: Cambridge University Press
Print publication year: 2016

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Book purchase

Temporarily unavailable

Accessibility standard: Unknown

Accessibility compliance for the PDF of this book is currently unknown and may be updated in the future.

Save book to Kindle

To save this book to your Kindle, first ensure no-reply@cambridge-org.demo.remotlog.com is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

  • File
  • Subrata Saha, Subhodip Mukherjee
  • Book: Basic Computation and Programming with C
  • Online publication: 17 July 2025
  • Chapter DOI: https://doi.org/10.1017/9781316551585.016
Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

  • File
  • Subrata Saha, Subhodip Mukherjee
  • Book: Basic Computation and Programming with C
  • Online publication: 17 July 2025
  • Chapter DOI: https://doi.org/10.1017/9781316551585.016
Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

  • File
  • Subrata Saha, Subhodip Mukherjee
  • Book: Basic Computation and Programming with C
  • Online publication: 17 July 2025
  • Chapter DOI: https://doi.org/10.1017/9781316551585.016
Available formats
×