You want tellp
. This is available for output streams (e.g., ostream, ofstream, stringstream).
There's a matching tellg
that's available for input streams (e.g., istream, ifstream, stringstream). Note that stringstream
supports both input and output, so it has both tellp
and tellg
.
As to keeping the two straight, the p
means put
and the g
means get
, so if you want the "get position" (i.e., the read position) you use tellg
. If you want the put
(write) position, you use tellp
.
Note that fstream
supports both input and output, so it includes both tellg
and tellp
, but you can only call one of them at any given time. If the most recent operation was a write, then you can call tellp
. If the most recent operation was a read, you can call tellg
. Otherwise, you don't get meaningful results.