A file is a place on disk where group of related data are stored. C supports a number of functions that have the ability to perform basic file operations, which include:Â
• Creating a new file
• Opening a fileÂ
• Reading data from a fileÂ
• Writing data to a fileÂ
• Closing the file
Why files are needed ?
When the program is terminated, the entire data is lost in C programming. If you want to keep large volume of data, it is time consuming to enter the entire data. But, if file is created, this information can be accessed using few commands.
Working with file :
While working with file, you need to declare a pointer of type file. This declaration is needed for communication between file and program.
Syntax : FILE *ptr;
C provides a number of functions that helps to perform basic file operations; all these functions are available in stdio library.