ios::in allows input (read operations) from a stream. ios::out allows output (write operations) to a stream.
ios::binaryOpens a file in binary mode. The default is text mode. You can combine these flags using a bitwise or operation. The binary flag, while portable, only has an effect on some non-UNIX systems, such as operating systems derived from MS-DOS, that have special conventions for storing end-of-line delimiters.
Both ios::ate and ios::app place the file pointer at the end of the file when it is opened. The difference between the two is that ios::app lets you add data to the end of the file only while the ios::ate mode when opened with ofstream allows you to write data anywhere in the file even over old data.
ios::app (short for append) means that instead of overwriting the file from the beginning, all output operations are done at the end of the file. This is only meaningful if the file is also open for output. ios::trunc (short for truncate) means that when the file is opened, the old contents are immediately removed.
I'm trying to figure out the difference between opening a file like:
fstream *fileName*("FILE.dat",ios::binary);
or
fstream *fileName*("FILE.dat",ios::out);
or
fstream *fileName*("FILE.dat",ios::binary | ios::out);
I found that all of these forms are identical: in all cases, the same output on the file is produced using either *fileName*<<
or *fileName*.write()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With