In C++, tellp() tells you where the next write will go. For a stream that you only write to from the start, this equals the number of characters written so far.
It pairs with seekp(): save a position, write something, and come back later. Include <iostream> to use it.
This is a member function of std::ostream. You call it with a dot on a stream object, for example std::cin, std::cout, a file stream, or a std::stringstream. A stream is simply C++'s way to read or write data one piece after another.
Syntax
Call tellp on an output stream. It takes no arguments.
C++
std::streampos here = out.tellp(); // bookmark
out << "text";
out.seekp(here); // go back
Call
What it does
out.tellp()
Returns the current write position.
out.tellp() - before
The number of characters written since before was saved.
out.seekp(here)
Goes back to a saved position.
Printing a number with << writes the digits too, so tellp() counts them.
Library declarations
C++
pos_type tellp();
Parameters
Parameter
Description
None
tellp() takes no parameters.
Return Value
Return Value
Description
std::streampos
The current write position, counted from the start.