1. What are different file stream classes? Explain the syntax of opening the file in read and write mode. Can while(fin) be replaced with if(fin1.eof()!=0) to process the file? Justify.
In c++ mainly there are three classes :
A) ofstream : This Stream Class is used to create files for writting information to files.
B) ifstream: This Streaam Class is used for reading information from files.
C) fstream: This Stream Class is used for both read and write from/to files.
Syntax : fopen("fileopen","mode");
"fileopen" is the path of the path on your device, "mode" is the mode in which file is opened i.e Read or Write mode.
while(fin) loop is used to return the value of an error flag variable within a class object fin, which is set to 0 when any function i.e read,write or opening fails. The loop runs till the read function inside the loop gets run.
Comments
Leave a comment