Files in C Tutorial

Bodhak files c tutorial in this chapter we are going o learn about Introduction to Files, Types of files, File Manipulating Functions, Formatted I/O Functions, Unformatted I/O Functions, Binary I/O File Functions,            I/O operations on records, Random Access Files, Command line arguments.

Introduction to Files: A file is a collection of information. Information may exist in different forms and this section Deals with how we can store this information in the form of data files.



files c tutorial

By default, different files are opened whenever we execute any program or interacting with any file. They are stdin, stdout, stderr, stdprn, stdaux. These files are opened and closed automatically and perform the stipulated respective actions. But in cases, we require making use of other files to store and retrieve data. C supplies a set of functions and structures to perform these actions

data in file

The data held by the file is in the form of character type, that is whatever may the data type dumped into the file, it is by default typecasts as char. So, Every individual character in a file occupies a byte. If the file contains the data in the form of image or graphical picture then it is the combination of pixels and that to further converted into characters. In general, when the file was created within the system, the O/S divides the file into data packets with a known size of 512 bytes and these bytes are unevenly scattered under the storage media but whose address is listed under file allocation table. On further access of the file the operating system refers the FAT and fetches the addresses and ultimately accesses the file.  The file are generally classified into various type based on their data format and type

In order to read the data from the file or write the data to the file, first that the file is to be opened. A file internal have to base references such are BOF (Beginning Of File) and EOF (End Of File). The BOF can be accessed with a built-in structure called FILE. It is conglomerate data type, which holds all the attributes of the file, Such are permissions, file type, data and time of access and size in bytes.


C Language is supported with rich set of library function, which can handle the text, binary, and executable file belongs to various systems