What are the different classes used for reading and writing to and from files in C++?

Different classes used for reading and writing to and from files are as follows:

Classes Description
ofStream This class is used for writing onto files
ifStream It is used for reading from files
fStream It is used for both reading and writing onto files

What are the different file opening modes in C++?

Different file opening modes in C++ are as follows:

Modes Description
ios::in Opens a file for reading. New contents cannot be written in the file.
ios::out Opens a file for writing. If file exist already then its contents are deleted but if the file does not exist it will create a new file.
ios::binary It opens a file in binary form.
ios::truncate Opens a file for writing. If file already exists then its previous contents are replaced with the new contents.
ios::app Opens a file in append mode. It adds new content at the end of the file.
ios::ate It is used to write new contents at the end of the file and we can also modify the previous contents.
ios::nocreate It does not allow to create a new file if it does not exist.
Ios::noreplace It does replace the old file with new file.

What are escape sequences?

Escape sequences are used with a ‘\’ backslash character and are used in printf statements in order to display the output of the program in a specific form. List of escape sequences:

Character Escape sequence

Double quotation mark \”
Single quotation mark \’
Question mark \?
Backslash \\
Beep \a
Backspace \b
Formfeed \f
Newlinw \n
Return \r
Tab \t