Answer to Question #180288 in C++ for Manisha gupta

Question #180288

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.


1
Expert's answer
2021-04-14T12:49:23-0400

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.


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS