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.
How to open and close files in C++?
More Questions
- What is a header file?
- What are the Friend functions?
- What are the different classes used for reading and writing to and from files in C++?
- What are Static data members and Static functions in C++?
- What are the different modes available for opening a file in C?
- What are the different file opening modes in C++?
- What are Files in C or C++?
- What is Function overloading?