Reputation: 1
I have two streams pointing to the same file. The first one is std::ofstream os
and the second is std::ifstream is
, both opened in binary mode.
I'm using os
to create a new file. The file creation process requires me to (at times) read data that was written to the file by os
. The is
stream seeks to the needed position, reads some data, and then os
does it's thing at its (distinct) offset and then flushes.
Is this legal to do? Will the streams stomp on each other?
Upvotes: 2
Views: 338
Reputation: 11414
Can´t quote any standard, but/because this is platform specific
(maybe exclusive access, buffering on different levels...)
You could just use a single fstream
with ios::in|ios::out
and seek before every action.
Upvotes: 0