DEFINING, OPENING AND CLOSING A FILE
When working with files, you need to declare a pointer of type file. This declaration is needed for communication between the file and program.
example : FILE *fptr;
Opening a file - for creation and edit
Opening a file is performed using the library function in the "stdio.h" header file: fopen(). The syntax for opening a file in standard I/O is:
ptr = fopen("fileopen","mode") For Example:
fopen("E:\\cprogram\\newprogram.txt","w"); fopen("E:\\cprogram\\oldprogram.bin","rb");
The writing mode allows you to create and edit (overwrite) the contents of the file.
Closing a file
fclose(fptr);