Introduction to file handling

Introduction to file handling 
File system basics
Standard streams in c
File structure
FILE pointer
Opening and closing a file
File handling functions
File types, Text and Binary
Input / Output operations on file
Reading a character using getc()
Writing a character using putc()
Using feof()
Working with string using fputs() and fgets()
Using fprintf() and fscanf()
Using fread() and fwrite()
Direct Access file

Introduction to file handling 

Main memory of the computing system is used to store temporary data that is processed to produce information. The data stored in memory is not permanent. When the system is switched off we lose the data stored in main memory. It is because of the volatile nature of main memory. But most of the time storing of data permanently for the sake of future reference is necessary. Of course in almost all organization storing of data is compulsory to produce very important resource "information". This data can be stored permanently only on the secondary storage like magnetic disk. The data on the secondary storage can be stored only through FILE. Without file nothing can be stored on the secondary storage.

Files are not only used to store data but also for other things. Our programs are also stored in the form of files are used widely in computers and play a pivotal role in data accessing. Contents are read from files and we write any contents in these files only. Various types of files are used in computers, but in C language we see two types of files namely, Text files and Binary files.
 File is nothing but a format to store data permanently on secondary storage device. A C programmer is interesting in handling the file to store data in two formats TEXT and BINARY

 The standard library 'stdio.h' in C has many files input/output functions. The file-handling functions are easy to use, powerful, and complete. We frequently use the files for storing data which can be processed by the programs. In order to store data permanently and retrieve it whenever required we need to use files.
 The editor which is used to enter the program and save it simply manipulates files. These files containing language statements are program files. The program can be translated by the compiler to make an object program. The object program is also a file. The object program is linked with other object programs to prepare an executable program. The executable program is also a file. But these all files are created and processed with operating system's file system. But using C language we organize the files to store the data in purely textual format or in binary format. The file contains data in the form of characters only is called as 'text file'. If the data is stored in the form of binary format then it is called as 'binary file'.


Post a Comment