Is there a way to open a file for both reading and writing?
As a workaround, I open the file for writing, close it, then open it again for reading. But is there a way to open a file for both reading and writing?
Is there a way to open a file for both reading and writing?
As a workaround, I open the file for writing, close it, then open it again for reading. But is there a way to open a file for both reading and writing?
Summarize the I/O behaviors:
| Mode | r | r+ | w | w+ | a | a+ |
|---|---|---|---|---|---|---|
| Read | + | + | + | + | ||
| Write | + | + | + | + | + | |
| Create | + | + | + | + | ||
| Cover | + | + | ||||
| Point in the beginning | + | + | + | + | ||
| Point in the end | + | + |
Decision tree for the table above: