File handling in C

(a) Describe briefly the use of file pointer.

File Pointer is a pointer that refers to a file on the secondary storage. It is a variable of type FILE that is defined in stdio.h. It is used to access and manipulate a data file. A program has to declare a file pointer to use a file. The file pointer is associated with a file after declaration. One file pointer can be associated with only one data file.
The syntax of declaring a file pointer is as follows:
FILE *MyFile;
The identifier MyFile is a file pointer.

(b) What are the different file handling modes in C language?

A data file in C language can be opened in the following modes:
r : The file is opened in read mode. The data can be read but cannot be written or modified.
w : The file is opened in write mode. The data can be written to the file. The existing data in the file is destroyed.
a : The file is opened in append mode. The new data is written at the end of existing data. The data cannot be read in this mode.
r+ : The file is opened in read/write mode. The data can be read and written to a file. The file must exist already.
w+ : The file is opened in read/write mode. The data can be read and written to a file. Existing data in the file is destroyed.
a+ : The file is opened in append mode. The new data is written at the end of existing data. The existing data can also be read.