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.