By opening a file you get a cursor into it. It’s the thing you move with seek.
When you read, say, 20 bytes from the file, the cursor moves forward 20 bytes, so the next read will return the next part.
When you write, say, 20 bytes to the file, the cursor moves forward 20 bytes, so the next write will write the next part. If the there was already something past where the cursor was pointing, and you write 20 bytes at that position, then 20 bytes of previous content get overwritten.
That much should be pretty clear; according to what you say, you already understand that.
Now, there’s no reason you need to always write or always read. You can read 20 bytes, then write 20 bytes; the cursor will now be before the 40th byte, waiting for your next action. Or you can seek around wildly, reading here, writing there, doing whatever wherever.
That’s all there is to it.
Still confused?
Makeshifts last the longest.
In reply to Re: Using +> for File Read/Write
by Aristotle
in thread Using +> for File Read/Write
by slloyd
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |