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.

More Questions

One Response to “What are the different file opening modes in C++?”

  1. selva says:

    very short and easy to understand.

Leave a Reply

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