|
First of all, we must understand that the file is opened by streambuf, not istream, nor ostream, so if in/out can operate on the same file, they need to be bound to the same streambuf, such as the filebuf above, so that you can The file is read and written.
Secondly, the two use the same pointer, so if you want to read after writing to filebuf, you have to call seekg(0) and return to the beginning |
|