How to open and close files in C++?

A header file fstream.h is used in order to work with the files in C++ which include functions for opening and closing files.
For opening a file:
In order to open a file open() member function of fstream’s class is used.
Syntax: open (filename, mode)
Here filename is the name of the file to open and mode can be mode available in C++.
For closing a file:
In order to close a file close() member function of fstream’s class is used. This function takes no arguments.

More Questions

Leave a Reply

Word Verfication * Time limit is exhausted. Please reload CAPTCHA.