Working with a file starts by opening it and ends by closing that file. But before doing anything with a file, you must create a variable as a file pointer. The syntax is
For the sake of simplicity, you'll often see fp used to represent a file pointer:
This variable is assigned a value during the process of opening the file for reading or writing. The file pointer will then point to all the information C needs to work with that file.
The functions used to read from and write to files reside in the stdio.h header file, which you're already including in your applications. The first function, fopen(), is used to initialize the file pointer:
fp = fopen (file_name, mode);
The file_name ...