iostream
was used for reading and writing into a program with the help of cin and cout.
Reading and writing into file can be done using fstream
standard library. fstream must be used as header file while doing input and output operations to a file along with iostream.
Modes | Description |
---|---|
in | Opens the file to read(default for ifstream) |
out | Opens the file to write(default for ofstream) |
binary | Opens the file in binary mode |
app | Opens the file and appends all the outputs at the end |
ate | Opens the file and moves the control to the end of the file |
trunc | Removes the data in the existing file |
nocreate | Opens the file only if it already exists |
noreplace | Opens the file only if it does not already exists |