difference seekp and seekg

Can anyone tell me in a simple way what is the difference between seekg and seekp? The tutorials are pretty much complex for me.
Thanks!
It is currently a flaw in many library implementations (and, IMHO, the specification itself).

There are supposed to be two positions associated with a file:

 • the “get” position (for reading)
 • the “put” position (for writing)

They are supposed to be independent and separately modifiable. They might not be.

Also, they are useless if you did not open the file in “binary” mode, which is another dumb flaw in the standard library.

tl;dr
Use seekp() to position the file position before writing.
Use seekg() to position the file position before reading.
If you use one, don’t for get to use the other.
Make sure to open in binary mode.

Hope this helps.
Registered users can post here. Sign in or register to post.