Today I saw an interesting piece of code:
ifstream fil;
fil.open( "ini.txt", std::ios::in | std::ios::out );
I was just about to talk about my weakness, but, to my surprise, I saw that cppreference.com seems to think that this is correct:
http://en.cppreference.com/w/cpp/io/basic_ifstream/open
mode - indicates the open stream mode. This is a bitmask type, the following constants are defined:
- in: open to reading
- out: open for recording
How can it ifstream
, which, as I understand it, is an INPUT file stream, is opened both for reading and writing?
Is this not necessary fstream
instead ifstream
?
source
share