Semester : S1 and S2
Subject : Computer Programming
Year : 2017
Term : DECEMBER
Branch : BIOTECHNOLOGY
Scheme : 2015 Full Time
Course Code : CS 100
Page:39
Here filename is the name of the file to be opened and mode specifies the
purpose of opening the file. Mode can be of following types,
*fp is the FILE pointer (FILE 0), which will hold the reference to the opened(or
created) file.
mode descriptionr opens a text
file in reading mode
Ww opens or create a
text file in writing mode. a
opens a text file in append
mode
mode 84 opens a text file in both reading
and writing mode rb opens
a binary file in reading mode
wb opens or create a binary
file in writing mode ab opens
a binary file in append mode
rb+ opens a binary file in both reading
and writing mode wb+ opens a binary
file in both reading and writing mode
ab+ opens a binary file in both reading
and writing mode
Closing a File
The fclose() function is used to close an already opened file.
General Syntax :
int felose( FILE *fp );
Here fclose() function closes the file and returns zero on success, or EOF if
there is an error in closing the file. This EOF is a constant defined in the
header file stdio.h.
Input/Output operation on File
In the above table we have discussed about various file I/O functions to perform
reading and writing on file. getc() and putc() are simplest functions used
to read and write individual characters to a file.
#include
#
ഠറ A OQ ८