Tagged: file operation in C

Opening a file in C 2

Opening a file in C

We can perform read and write operations on a file in C. But, before that we must open a file. To open a file in C, we have to call the function fopen() as shown below: FILE *fp; fp = fopen(“file1.C”,”r”); The above statement would open file named “file1.C” in “read” mode. It tells the computer that the file being opened would be used for reading purpose only. fopen()¬†performs three important tasks when you open the file in “r” mode: Firstly, it searches the file to be opened on the disk Then it loads the file from the disk into...