Reputation: 2815
With
fstream file("test.txt",ios_base::in | ios_base::out | ios_base::binary);
are tellp
and tellg
the same for file
? Or seekp
and seekg
?
Upvotes: 1
Views: 749
Reputation: 47438
Yes, std::filebuf
, the buffer used by std::fstream
, has only one pointer. seekg
and seekp
move the same pointer, and tellg
and tellp
return its position.
(an example of a stream where the pointers are different is std::stringstream
)
The standard specifies this in §27.9.1.1[filebuf]/3
A joint file position is maintained for both the input sequence and the output sequence
Upvotes: 3