are “seekp” & “seekg” interchangeable?

For file positions they are the same. In other words there is only one pointer maintained.

From 27.9.1.1p3:

A joint file position is maintained for both the input sequence and
the output sequence.

So, seekg and seekp are 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.

Leave a Comment