Well I just noticed that by changing the position -in microsoft visual studio- through “seekp” I implicitelly also change the read-position, when handling files.
I am wondering however if this is “portable” behaviour? Can I expect the position of reading & writing to be always the same? And consequently: will tellp & tellg always return the same value?
For file positions they are the same. In other words there is only one pointer maintained.
From
27.9.1.1p3:So,
seekgandseekpare interchangeable for file streams. However, this is not true for other types of streams, as they may hold separate pointers for the put and get positions.